Home  >  Article  >  Web Front-end  >  css border实现的三角形图案_html/css_WEB-ITnose

css border实现的三角形图案_html/css_WEB-ITnose

WBOY
WBOYOriginal
2016-06-24 11:26:03970browse

css中border的作用相信大家都知道,它的作用是用于设置边框,但是对于css border如何实现三角形图案,估计有很多朋友多不知道如何实现。本文章向大家介绍css border如何实现绚丽多彩的三角形图案。

 

利用css控制border的边框属性, 可以画出三角形,下面一步一步演示给大家看:

先看下面代码代码如下:

<style>div{    width:200px;    height:200px;    border-top:50px solid yellow;    border-right:50px solid red;    border-bottom:50px solid purple;    border-left:50px solid blue;}</style><div></div>

效果如下图:

如果我们将idth和height设为0,又会是什么样的呢:

<style>div{    width:0px;    height:0px;    border-top:50px solid yellow;    border-right:50px solid red;    border-bottom:50px solid purple;    border-left:50px solid blue;}</style><div></div>

效果图如下:

从图中可以看出,我们已经有了四个的三角形,如果只需要一个三角形,该怎么实现呢?很简单,只需要将其他三个边框的颜色设为透明transparent即可。

代码如下:

<style>div{    width:0px;    height:0px;    border-top:50px solid transparent;    border-right:50px solid transparent;    border-bottom:50px solid transparent;    border-left:50px solid blue;}</style><div></div>

效果图:

好了,效果达成了,大家现在应该知道怎么实现了吧,其实很容易。

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn