CSS triangle, css triangle

Source: Internet
Author: User

CSS triangle, css triangle

Set the border attribute of the div!

SetHeightAndWidth attributeSet0px, returns the border Value of the 4-sideSetSame Width, You can see the effect by adjusting the border color class.

<style>    div{height: 0px;width: 0px;        border-top: 20px solid red;        border-left: 20px solid blue;        border-right: 20px solid gray;        border-bottom: 20px solid pink;    }    </style>

You can get a square composed of four triangles. For example:

Next, you only need to remove the color of the other three sides to get the triangle.Border-color is transparentIn this case, you can get the triangle.

div{height: 0px;width: 0px;        border-top: 20px solid red;        border-left: 20px solid transparent;        border-right: 20px solid transparent;        border-bottom: 20px solid transparent;    }

The result is as follows:

In addition, transparent is the color value, equivalent to rgba (0, 0, 0), transparency is 0. However, it is not supported in IE6 and will be displayed by default as follows:

 

======================================================= =

 

div{        height: 0;        width: 0;        border-top: 100px solid red;        border-left: 100px solid transparent;    }

Occasionally, Baidu saw that such a setting would form two triangles, which were not previously expected. Therefore, it was recorded. Hey hey, the effect is as follows:

Add a pseudo-class method after testing.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.