美文网首页
画0.5px的线

画0.5px的线

作者: miao8862 | 来源:发表于2021-05-06 20:11 被阅读0次

第一种:viewport的meta标签

使用html的meta标签,在viewport类型内容写上initial-scale=0.5, maxinum-scale=0.5, mininum-scale=0.5,此时,在移动端的1px就等于0.5了
缺点:

  1. 只针对移动端,在PC端不生效;

第二种:使用transform:scale

使用css样式,transform: scale(0.5, 0.5);

<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <!-- 第一种,viewport只针对移动端,只能在移动端上看到效果,1px就等于为0.5px -->
  <meta name="viewport" content="width=device-width, initial-scale=0.5, maxinum-scale=0.5, mininum-scale=0.5">
  <title>画一条0.5px的线</title>
  <style>
    .half-px {
      /* 第二种,使用transform:scale */
      transform: scale(0.5, 0.5);
      border-bottom: 1px solid red;
    }
  </style>
</head>
<body>
  <div class="half-px"></div>
</body>
</html>

参考:https://blog.csdn.net/qq_42068550/article/details/101162325

相关文章

网友评论

      本文标题:画0.5px的线

      本文链接:https://www.haomeiwen.com/subject/tttkdltx.html