1. 程式人生 > >用偽元素寫移動端1px邊框時想實現邊角效果

用偽元素寫移動端1px邊框時想實現邊角效果

ack img ive cal left image event 發現 邊框

做移動端頁面時,又想用偽元素做真實1像素邊框,又想有邊角時,會發現只加一個border-radius時出來的效果邊款並沒有變成圓角,解決辦法是加兩個border-radius

<div class="white_wrap border b_all">
</div>
.white_wrap{margin:1.5rem 1.5rem 0 1.5rem;background-color:#fff;border-radius:6px;}
.border{ position:relative;}
.border:after{ content:""; position:absolute
; left:0; top:0; right:-100%; bottom:-100%; -webkit-transform:scale(0.5); -webkit-transform-origin:0 0; pointer-events:none;} .b_all:after{ border:1px solid #e3e4e5;border-radius: 12px;} //註意偽元素的圓角設成2倍

技術分享

圖中邊框用了真實1px,在pc端看可能不太明顯

用偽元素寫移動端1px邊框時想實現邊角效果