移動端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