解决0.5px在部分机型上面的兼容显示

.num-box {
    position: relative;
    overflow: hidden;
}
.num-box::before {
    position: absolute;
    top: 0;
    left: 0;
    box-sizing: border-box;
    width: 200%;
    height: 200%;
    border: 0.01rem solid #ff60a9;
    transform: scale(0.5);
    content: '';
    transform-origin: left top;
}

使用scale(0.5)来解决px小的时候的展示问题

除了 iPhone(iOS8以上),目前绝大多数的移动设备并不支持直接渲染 0.5px 的边框,都会把0.5识别为0,即无边框状态

扩展:

scale(0.5)还可以用来解决移动端上下不居中的问题

posted @ 2021-08-25 11:25  瑞瑞大人  阅读(225)  评论(0编辑  收藏  举报