画一条 0.5 px 的线

1.transform:scale(0.5)

<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        .half-px{/*height为0.5px的直线时,浏览器会四舍五入为1px的直线 */
            background-color: aqua;
            height: 0.5px;
        }
        .half-px1{
            background-color: aqua;
            height: 1px;
            transform: scale(0.5);/*使用缩放功能将直线缩放0.5倍*/
        }
    </style>
</head>
<body>
    <div style="width: 20px; height: 20px;"></div>
    <div class="half-px"></div>
    <div style="width: 200px; height: 20px;"></div>
    <div class="half-px1"></div>
</body>
</html>

2.meta viewport的方式

<meta name="viewport" content="width=device-width,initial-sacle=0.5">
//只有在移动端才能看到效果

3.canvas

<body>
    
  <canvas id="drawing" width=" 200" height="200">A drawing of something.</canvas>
  <script>
      var drawing = document.getElementById("drawing");
      if(drawing.getContext){
          var context = drawing.getContext("2d");
          context.lineWidth = 0.5;
          context.beginPath(); 
          context.moveTo(30, 30); 
          context.lineTo(200, 100);
          context.stroke(); 
      }
  </script>
</body>

4.SVG

 <svg id="svgLineTutorial"  height="200px" width="200px" xmlns="http://www.w3.org/2000/svg">
        <line x1="50" y1="50" x2="200" y2="200" style="stroke:Green;stroke-width:0.5"/>
    </svg>
    <svg id="svgLineTutorial"  height="200px" width="200px" xmlns="http://www.w3.org/2000/svg">
        <line x1="50" y1="50" x2="200" y2="200" style="stroke:Green;stroke-width:1"/>
    </svg>

5.设置box-shadow

    .d2 {
      width: 100px;
      height: 100px;
      background-color: yellowgreen;
      box-shadow: 0 0.5px grey;
    }

6.设置border

    .d1 {
      width: 100px;
      height: 100px;
      background-color: yellow;
      border-bottom: 0.5px solid black;
    }

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值