移动端1px细线解决方案--利用transform缩放方式


移动端1px会显示为2px; 

解决方式很多,这里介绍比较常用的一种方式--css的transform属性缩放

1. 上边框 相当于 border-top

<div class="bordert1px"></div>

css

/*top*/
.bordert1px {
    position: relative;
}
.bordert1px:before {
    content: " ";
    position: absolute;
    left: 0;
    top: 0;
    width: 100%;
    height: 1px;
    background-color: #d8d8d8;
    -webkit-transform-origin: 0 0;
    transform-origin: 0 0;
    -webkit-transform: scaleY(0.5); 
    transform: scaleY(0.5); // 纵向缩放
}

细线--直接缩放就好了

<hr />

css

hr{background: #d8d8d8;width:1px;height:1rem;border:none;transform: scaleX(0.5);margin: 0;}

 如果使用vux的话,vux也提供了1px解决方案 https://doc.vux.li/zh-CN/css/1px.html


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM