极细边框(1px边框)实现方式
像素基本概念(术语)
设置0.5px边框
//判断手机是否支持0.5px
if (window.devicePixelRatio && devicePixelRatio >= 2) {
var divElem = document.createElement('div')
divElem.style.border = '.5px solid transparent'
document.body.appendChild(divElem)
if (divElem.offsetHeight == 1) {
document.querySelector('html').classList.add('hairlines');
}
document.body.removeChild(divElem);
}
//在html中,加上此样式
.hairlines {
*:not(table tr td),
*:not(.noHairlines) {
border-width: 0.5px!important;
}
}box-shadow(阴影)
border-image(边框背景图片)
background-image 渐变
transform: scale(0.5) (推荐,相当灵活)
viewport+rem
常见问题
细边框显示不全

参考链接
最后更新于