王新阳

wangxinyang

CSS3实现三角形

<div class="arrow-up"><!--向上的三角--></div>
<div class="arrow-down"><!--向下的三角--></div>
<div class="arrow-left"><!--向左的三角--></div>
<div class="arrow-right"><!--向右的三角--></div>

/*箭头向上*/
.arrow-up {
width:0;
height:0;
border-left:30px solid transparent;
border-right:30px solid transparent;
border-bottom:30px solid #fff;
}

/*箭头向下*/
.arrow-down {
width:0;
height:0;
border-left:20px solid transparent;
border-right:20px solid transparent;
border-top:20px solid #0066cc;
}

/*箭头向左*/
.arrow-left {
width:0;
height:0;
border-top:30px solid transparent;
border-bottom:30px solid transparent;
border-right:30px solid yellow;
}

/*箭头向右*/
.arrow-right {
width:0;
height:0;
border-top:50px solid transparent;
border-bottom: 50px solid transparent;
border-left: 50px solid green;
}

再配合 transform:rotate(xdeg) 就可以实现各方向的三角形了。

来源:https://www.cnblogs.com/huanghuali/p/6145604.html

2018-08-22
2024-11-23 星期六 农历十月二十三