ReinerLau1 / Blog

Just a blog
MIT License
0 stars 0 forks source link

如何解决 1px 问题 #267

Closed ReinerLau1 closed 2 years ago

ReinerLau1 commented 2 years ago

概念

ReinerLau1 commented 2 years ago

解决一

#container[data-device="2"] {
  border:0.5px solid #333
}
ReinerLau1 commented 2 years ago

解决二

const scale = 1 / window.devicePixelRatio;
// 这里 metaEl 指的是 meta 标签对应的 Dom
metaEl.setAttribute('content', `width=device-width,user-scalable=no,initial-scale=${scale},maximum-scale=${scale},minimum-scale=${scale}`);