Use CSS3 to make squares, triangles, slices, and pie charts

Source: Internet
Author: User
Tags transparent color

1. Make a square with a border

If you set the width and height of the box container to 0 and set a thicker width value for each edge and a different color from each other, you will end up with four triangles, each pointing to a different color.

HTML code: <div id= "Square" >11</div>

CSS3 Code:

#square {
width:0;
height:0;
border-width:100px;
Border-style:solid;
Border-color:red Blue green yellow;
Line-height:99em;
Overflow:hidden;
Cursor:pointer;
margin:30px Auto;
}

Display effect:

Visible from the diagram, the four triangles point in different directions.

2. When we set the color of the three of the four triangles to be transparent or transparent, we can get a triangle

Html:

<div id= "Triangle" >11</div>

Css:

#triangle {
width:0;
height:0;
border-width:100px;
Border-style:solid;
border-color:red transparent transparent transparent;
Line-height:99em;
Overflow:hidden;
Cursor:pointer;
margin:30px Auto;
}

Effect:

3. You should be aware that the fillet attribute (Border-radius) is introduced in CSS3, and once this value is set, the border will appear rounded. Similarly, we have rounded corners of the squares to get a pie chart

Html:<div id= "Circle" >11</div>

Css:

#circle {

width:0;
height:0;
border-radius:100px;
border-width:100px;
Border-style:solid;
Border-color:red Blue green yellow;
Line-height:99em;
Overflow:hidden;
Cursor:pointer;
margin:30px Auto;


}

Effect:

4. We also set the transparent color of three of these frames to get a fan

Html:<div id= "Fan" >11</div>

Css:

#fan {

width:0;
height:0;
border-radius:100px;
border-width:100px;
Border-style:solid;
border-color:red transparent transparent transparent;
Line-height:99em;
Overflow:hidden;
Cursor:pointer;
margin:30px Auto;

}

Effect:

Use CSS3 to make squares, triangles, slices, and pie charts

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.