CSS3可以做動畫、畫簡單的幾何圖形,只要瀏覽器兼容,重慶網站建設可以做出非常豐富的網頁設計效果,秀站網秀站網介紹用CSS3畫三角形并實現旋轉效果。
CSS樣式部分
.jiao{position:relative;width:22px;height:22px;line-height:22px;} .jiao i{ position:absolute; top:10px; right:10px; width:0px; height:0px; zoom:1; font-weight:500; font-style:normal; border-color:transparent transparent #000; border-style:solid; border-width:0px 4px 4px 4px; -webkit-transition: -webkit-transform 0.2s ease-in; -moz-transition:-moz-transform 0.2s ease-in; -o-transition:-o-transform 0.2s ease-in; transition:transform 0.2s ease-in; } .jiao:hover i{ -moz-transform:rotate(180deg); -webkit-transform:rotate(180deg); -o-transform:rotate(180deg); transform:rotate(180deg); filter:progid:DXImageTransform.Microsoft.BasicImage(rotation=2); }
HTML部分
<p class="jiao"><i></i></p>
注意:這個效果三角形是箭頭朝上,圍繞著中心旋轉的。
其他三角形繪制方法
下面所說的等三角形其實并不等邊,而是高度寬高比例1:1。
等三角形-箭頭朝上
.jiao i{ width:0; height:0; border-left: 4px solid transparent; border-right: 4px solid transparent; border-bottom: 8px solid #000;}
等三角形-箭頭朝下
.jiao i{ width:0; height:0; border-left:4px solid transparent; border-right:4px solid transparent; border-top:8px solid #000;}
等三角形-箭頭朝左
.jiao i{ width:0; height:0; border-top:4px solid transparent; border-right:4px solid #000; border-bottom:8px solid transparent;}
等三角形-箭頭朝右
.jiao i{ width:0; height:0; border-top:4px solid transparent; border-left:4px solid #000; border-bottom:8px solid transparent;}
等邊直角三角形-直角在左上
.jiao i{ width:0; height: 0; border-top:8px solid red; border-right:8px solid transparent;}
等邊直角三角形-直角在右上
.jiao i{ width: 0; height:0; border-top:8px solid red; border-left:8px solid transparent;}
等邊直角三角形-直角在右下
.jiao i{ width:0; height:0; border-bottom:8px solid red; border-left:8px solid transparent;}
等邊直角三角形-直角在左下
.jiao i{ width:0; height:0; border-bottom:8px solid red; border-right:8px solid transparent;}