经常碰到这种细边框的情况,我们可以通过缩放来实现功能。本质就是,我们需要一条1px的线,按照需求纵向或者横向缩放一定的比例,然后再通过定位固定到相应的位置。所以对于使用:after或者:before并没有什么约束,要记住我们需要的只是1px的辅助元素。
下边是我项目中的实现方案
.content .selectContent li{
position: relative;
}
.content .selectContent li:after { //下边框
content: " ";
position: absolute;
left: 0;
bottom: 0;
width: 100%;
height: 1px;
background: #8B8B8B;
transform: scaleY(0.25);
}
.content .selectContent li:nth-child(odd):before { //右边框
content: " ";
position: absolute;
right: 0;
top: 0;
width: 1px;
height: 100%;
background: #8B8B8B;
transform: scaleX(0.25);
}
效果