0.5px 线的解决方法

<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8" />
  <meta http-equiv="X-UA-Compatible" content="IE=edge" />
  <meta name="viewport" content="width=device-width, initial-scale=1.0" />
  <title>0.5px的</title>
  <style>
    .hr {
      width: 300px;
      background-color: #000;
    }

    /*  */
    .hr.scale-half {
      height: 1px;
      transform: scaleY(0.5);
      transform-origin: 50% 100%;
    }

    .hr.half-px {
      height: 0.5px;
      transform-origin: 50% 100%;
    }

    .hr.one-px {
      height: 1px;
      transform-origin: 50% 100%;
    }

    .hr.two-px {
      height: 0.5px;
      /* 具体解决是虚线的,感觉没啥用 */
      -webkit-text-size-adjust: none;
      font-size: 1px;
    }
  </style>
</head>

<body>
  <p>1px + scaleY(0.5)</p>
  <div class="hr scale-half"></div>
  <p>0.5px</p>
  <div class="hr half-px"></div>
  <p>1px</p>
  <div class="hr one-px"></div>
  <p>self</p>
  <div class="hr two-px">hahsdhfa</div>
</body>

</html>

 

posted @ 2022-10-09 23:14  小忱  阅读(35)  评论(0)    收藏  举报