1px

Retina屏的移动设备如何实现真正1px的线?

<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0, user-scalable=no">
    <title></title>
</head>
<body>
    <div style="100px;height:0.5px;background:red;margin:10px;"></div>

    <div style="100px;height:1px;background:red;margin:10px;"></div>

    <div style="100px;height:1px;background:red;margin:10px;-webkit-transform: scaleY(0.5);transform:scaleY(0.5);-webkit-transform-origin:0 0;transform-origin: 0 0;"></div>
</body>
</html>

if (window.devicePixelRatio && devicePixelRatio >= 2) {
  var testElem = document.createElement('div');
  testElem.style.border = '.5px solid transparent';
  document.body.appendChild(testElem);
  if (testElem.offsetHeight == 1)
  {
    document.querySelector('html').classList.add('hairlines');
  }
  document.body.removeChild(testElem);
}
原文地址:https://www.cnblogs.com/jzm17173/p/4819688.html