由于dpr导致写的border:1px red solid;并不能在手机上实现真正的1像素。
通过伪类实现手机端一像素的代码:
@mixin border_bottom($color) {
& {
position: relative;
&:before {
content: \"\";
position: absolute;
top: 0;
left: 0;
border-bottom: 1px solid $color;
transform-origin: 0 0;
padding: 1px;
box-sizing: border-box;
pointer-events: none;
}
&:last-child:before {
border-bottom:none;
}
}
@media (-webkit-min-device-pixel-ratio:1),(min-device-pixel-ratio:1) {
&:before {
width: 100%;
height: 100%;
transform: scale(1);
}
}
@media (-webkit-min-device-pixel-ratio:2),(min-device-pixel-ratio:2) {
&:before {
width: 200%;
height: 200%;
transform: scale(0.5);
}
}
@media (-webkit-min-device-pixel-ratio:3),(min-device-pixel-ratio:3) {
&:before {
width: 300%;
height: 300%;
transform: scale(0.333);
}
}
}
使用的时候:
.li {
width: 100px;
min-height: 40px;
@include border_bottom(#ff0000);
}
继续阅读与本文标签相同的文章
-
尘埃落定!美盟友明确表示不排除华为5G:特朗普颜面尽失!
2026-05-18栏目: 教程
-
“中本聪”一词被收入牛津英语词典
2026-05-18栏目: 教程
-
中山5G建设传重磅消息!市民何时能用?时间定了!
2026-05-18栏目: 教程
-
调查显示中国88%员工信任机器人超过经理
2026-05-18栏目: 教程
-
在如今,人们谈到科技,可能最先想到的就是电子技术
2026-05-18栏目: 教程
