通过伪类元素画0.5px细线

在H5开发中,经常会需要给div元素添加边框,我们往往会设置1pxborder,不过在真机显示上看,1px的边框看起来比较粗,影响美观,所以,可以用通过伪类元素设置1px宽度边框的同时配合transform来缩小一倍的宽度来实现即可。以下是代码:

.line_btm {
    position: relative
}

.line_btm:before {
    content: " ";
    position: absolute;
    z-index: 3;
    left: 0;
    bottom: -1px;
    width: 100%;
    height: 1px;
    border-bottom: 1px solid #D9D9D9;
    -webkit-transform-origin: 0 0;
    transform-origin: 0 0;
    -webkit-transform: scaleY(.5);
    transform: scaleY(.5)
}
发布了10 篇原创文章 · 获赞 0 · 访问量 155

猜你喜欢

转载自blog.csdn.net/weixin_39782183/article/details/104718255