最近微信推出他們本身的H5組件(weui)組件的優勢有兩個:css
當用手指觸摸某個按鈕的時候,按鈕會變成深色,離開後按鈕顏色自動恢復,這個效果讓用戶的體驗感倍增。html
正常狀況下網頁的 border 屬性是沒有 0.5 這個值的,咱們看下效果web
上面是 0.5 像素的邊框,下面是 1 像素的邊框,從肉眼上就能夠看出差異。微信
代碼以下:ui
<div class="weui_cells"> <div class="weui_cell"> <div class="weui_cell_bd weui_cell_primary"> <p>我是0.5像素</p> </div> <div class="weui_cell_ft">說明文字</div> </div> </div> <style> .weui_cells_a:before { content: " "; position: absolute; left: 0; right : 0; width: 100%; height: 1px; border-top: 1px solid #D9D9D9; color: #D9D9D9; -webkit-transform-origin: 0 0; transform-origin: 0 0; -webkit-transform: scaleY(0.5); transform: scaleY(0.5); /*這是before和after之間的區別*/ top: 0; } .weui_cells_a:after { content: " "; position: absolute; left: 0; right : 0; width: 100%; height: 1px; border-bottom: 1px solid #D9D9D9; color: #D9D9D9; -webkit-transform-origin: 0 100%; transform-origin: 0 100%; -webkit-transform: scaleY(0.5); transform: scaleY(0.5); /*這是before和after之間的區別*/ bottom: 0; } </style>