因爲安卓手機沒法識別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