<div class="box"></div>
<style>
.box{
width: 0; height: 0; border-top: 50px solid transparent; border-bottom: 50px solid transparent; border-left: 50px solid transparent; border-right: 50px solid red; }
</style>
<div class="box"></div> <style> .box{ width: 50px; height: 50px; margin: 100px auto; background-color: red; transform: skew(-25deg); } </style>
<div class="box"></div> <style> .box{ width: 50px; height: 50px; margin: 100px auto; color: #000; border: 1px solid; border-radius: 50%; outline: 10px solid; outline-offset: -26px; } </style>
暫停按鈕的實現原理就是邊框用border,裏面的正方形用outline。由於outline有一個offset屬性能夠用來設置偏移量,而且是按照比例來的。web
其實若是再將outline-offset的值設置小一點,一個加好就出來了瀏覽器
<div class="box"></div> <style> .box{ width: 50px; height: 50px; margin: 100px auto; color: #000; border: 1px solid; border-radius: 50%; outline: 10px solid; outline-offset: -35px; } </style>
若是再將其旋轉,就變成了一個關閉按鈕函數
<div class="box"></div> <style> .box{ width: 50px; height: 50px; margin: 100px auto; color: #000; border: 1px solid; border-radius: 50%; outline: 10px solid; outline-offset: -35px; transform: rotate(45deg); }
<div class="box"></div> <style> .box{ width: 50px; height: 0px; margin: 100px auto; box-shadow: 36px 10px 0 3px red, 36px 0 0 3px red, 36px 20px 0 3px red; } </style>
<div class="box"></div> <style> .box{ width: 30px; height: 3px; margin: 100px auto; padding: 2px 0; border-top: 3px solid red; border-bottom: 3px solid red; background-clip: content-box; background-color: red; } </style>
由於box-shadow會按比例縮放,所以將第一個值設置爲白色,而後將第二個值設置的比第一個值大就能夠了spa
<div class="box"></div> <style> .box{ width: 30px; height: 30px; margin: 100px auto; background-color: #000; border-radius: 50%; box-shadow: 0 0 0 5px #fff,0 0 0 10px #000; } </style>
<div class="box"></div> <style> .box { width: 30px; height: 30px; margin: 100px auto; background-color: #000; border-radius: 50%; box-shadow: 0 0 0 5px #fff, 0 0 0 10px #000; outline: 36px solid #fff; outline-offset: -50px; } </style>
<div class="box"></div> <style> .box { width: 0; margin: 100px auto; border: 3px solid red; outline: 6px dotted red; outline-offset: 6px; } </style>
使用border製做三角形,使用box-shadow製做正方形,主要用了偏移3d
<div class="box"></div> <style> .box { width: 0; margin: 100px auto; color: red; border: 8px solid transparent; border-top: 8px solid red; box-shadow: 0 -12px 0 -4px; } </style>
實現這種效果的原理就是講三角形設置成背景色,這樣空心的三角形就出現了code
<div class="box"></div> <style> .box { width: 0; height: 8px; background-color:orange; border: 8px solid transparent; border-bottom: 8px solid #fff; } </style>
這個比較簡單,就是經過漸變函數來實現,而後來個圓角邊框orm
<div class="box"></div> <style> .box { width: 50px; height: 50px; border-radius: 50%; background-image: linear-gradient(to right,#ccc 50%,#000 50%); } </style>
外圈利用圓角邊框,裏面的豎線用漸變來作,而後再用旋轉屬性便可blog
<div class="box"></div> <style> .box { width: 50px; height: 50px; border-radius: 50%; border:2px solid #000; background: linear-gradient(to right,#fff 45%,#000 45%,#000 45%,#fff 55%); transform: rotate(40deg); } </style>
既然能作出一個三角形,那麼就能夠作出兩個三角形。ip
<div class="box"></div> <style> .box { width: 0; height: 0; margin: 100px auto; border: 10px solid transparent; border-left: 10px solid red; -webkit-box-reflect: left 5px; box-reflect:left 5px; } </style>
須要在Chrome瀏覽器中打開,由於其餘瀏覽器或許不支持it
<div class="box"></div> <style> .box { width: 32px; margin: 100px auto; border-top: 50px solid transparent; border-right: 22px solid #096; border-bottom-right-radius: 100%;; } </style>