京东采用伪元素::before 设置200%尺寸在使用transform缩小一倍的方案
代码
.p {
width: 40px;
height: 16px;
position: relative;
line-height: 16px;
text-align: center;
font-size: 12px;
color: #000;
margin: 10px;
&::after {
content: '';
position: absolute;
top: 0;
left: 0;
width: 200%;
height: 200%;
transform: scale(0.5);
transform-origin: 0 0;
border: 1px solid red;
}
}
测试代码
很奇怪 0.5的只是比1px的颜色谈了点