怎样应用css画出一个三角形
发布时间:09/01 来源:未知 浏览:
关键词:
(视频教程引荐:css视频教程)
实现代码:
<!DOCTYPE html> <html> <head> <title></title> <style type="text/css"> /* css3绘制三角形 */ .triangle{ width: 0px; /*设定宽高为0,所以div的内容为空,从才能构成三角形尖角*/ height: 0px; border-bottom: 200px solid #00a3af; border-left: 200px solid transparent; /*transparent 表示透亮*/ border-right: 200px solid transparent; } </style> </head> <body> <div class="triangle"></div> </body> </html>
还是不睬解的小伙伴可以看下面
1、设定div有必然宽高,四边设定边框
.triangle{ width: 50px; height: 50px; border-top: 200px solid #00a497; border-bottom: 200px solid #cc7eb1; border-left: 200px solid #165e83; border-right: 200px solid #c85179; }
上面代码设定div有必然宽高,四边设定边框时,结果如下:
2、设定div宽高为0,四边设定边框宽度为200px
.triangle{ width: 0px; height: 0px; border-top: 200px solid #00a497; border-bottom: 200px solid #cc7eb1; border-left: 200px solid #165e83; border-right: 200px solid #c85179; }
上面代码设定div宽高为0,四边边框设定不一样色彩时,结果如下:
(相关教程引荐:CSS教程)
3、接下来div宽高仍为0,去除border-top
.triangle{ width: 0px; height: 0px; border-bottom: 200px solid #cc7eb1; border-left: 200px solid #165e83; border-right: 200px solid #c85179; }
上面代码设定div宽高为0,只设定下边框和摆布边框时,结果如下:
4、最后发明,只将border-bottom设定色彩,摆布边框透亮,既可得到三角形
.triangle{ width: 0px; height: 0px; border-bottom: 200px solid #cc7eb1; border-left: 200px solid transparent; border-right: 200px solid transparent; }
终究结果:
以上就是怎样利用css画出一个三角形的具体内容,更多请关注百分百源码网其它相关文章!