衆所周知在移動端寫1px邊框,顯示出來的效果看起來比較粗,而且在不同的移動設備顯示效果也千差萬別,那麼下面介紹一種常見的0.5px 的實現方法。
下面代碼可以實現4條邊框:
Container: {
position: 'relative',
width: '100%',
height: theme.typography.pxToRem(666),
padding: theme.typography.pxToRem(15),
textAlign: 'center',
borderRadius: 3,
// border: '1px solid #F2F2F2',
'&:before': {
content: '""',
display: 'block',
position: 'absolute',
left: '-50%',
top: '-50%',
width: '200%',
height: '200%',
border: '1px solid red',
transform: 'scale(0.5)',
borderRadius: 3
}
},
看看對比圖,在移動端效果很明顯: