因为安卓手机没法识别border: 0.5px
,所以咱们要用0.5px的话必需要借助css3中的-webkit-transform:scale
缩放来实现。css
原理:将伪元素的宽设为200%,height设为1px经过-webkit-transform:scale(.5)
来进行缩小一倍,这样就获得border为0.5的边框html
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <meta http-equiv="X-UA-Compatible" content="ie=edge"> <title>Document</title> <style> .div{ width: 100%; height: 100px; border-top: 1px solid aqua; posititon:relative; } .div::after{ content: ''; position: absolute; left: 0; bottom: 0; box-sizing: border-box; width: 200%; height: 1px; transform: scale(.5); transform-origin: 0 0; pointer-events: none; background-color: aqua; } </style> </head> <body> <div class="div"></div> </body> </html>Copy to clipboardErrorCopied
效果展现:css3