使用CSS绘制三角形

Winter

2020-06-03

使用CSS就可以绘制各种形状的三角形,不用使用iconfont或者图片什么的。

1.向上的三角形

.triangle-up {
    width: 0;
    height: 0;
    border-left: 50px solid transparent;
    border-right: 50px solid transparent;
    border-bottom: 100px solid #435a85;
}

2.向下的三角形

.triangle-down {
    width: 0;
    height: 0;
    border-left: 50px solid transparent;
    border-right: 50px solid transparent;
    border-bottom: 100px solid #435a85;
}

3.向左的三角形

.triangle-left {
    width: 0;
    height: 0;
    border-top: 50px solid transparent;
    border-bottom: 50px solid transparent;
    border-right: 100px solid #435a85;
}

4.向右的三角形

.triangle-right {
    width: 0;
    height: 0;
    border-top: 50px solid transparent;
    border-bottom: 50px solid transparent;
    border-left: 100px solid #435a85;
}

 

第4253篇《使用CSS绘制三角形》来自Winter(https://github.com/aiyld/aiyld.github.io)的站点

0条评论