需要的效果(下图中任意一个颜色的三角形)
以上图案实现的代码
.box{
width: 0px;
height: 0px;
border-bottom: 100px solid #6cf;
border-left: 100px solid #ccc;
border-right: 100px solid #0a0;
border-top: 100px solid red;
}
css写三角形,是使用了border属性进行完成的,当我们需要哪个颜色块角度的三角形,就将其余三个方位的颜色改成transparent(透明)即可
例如:
代码如下:
.box{
width: 0px;
height: 0px;
border-bottom: 100px solid transparent;
border-left: 100px solid transparent;
border-right: 100px solid #0a0;
border-top: 100px solid transparent;
}