Skillfully using CSS border

Source: Internet
Author: User

    • A smooth slash appears at the junction of the top and bottom borders. Using this feature, by setting different upper and lower left and right border width or color, you can get the small triangle, trapezoid and so on.
    • Adjust the width size to adjust the triangle shape.

Implementing triangles

Example 1:

#test1 {    height:20px;     width:20px;     border-color:#FF9600 #3366ff #12ad2a #f0ed7a;     border-style:solid;     border-width:20px;}

Example 2:

Based on the above, the height width is set to 0 o'clock, and the boundary slash is rendered.

#test2{Height:0;width:0;Overflow:Hidden;/*here set overflow, font-size, Line-height*/font-size:0;/*is because, although the width height is 0, the IE6 will have a default*/Line-height:0;/*font size and line height, resulting in the box being stretched long rectangle*/Border-color:#FF9600 #3366ff #12ad2a #f0eb7a;Border-style:Solid;Border-width:20px;}

Example 3:

In Example 2 you can see that there are 4 triangles, if you put 4 colors, only one color, the remaining 3 colors are set to transparent or the same as the background color, then form a triangle.

{    height:0;     width:0;     Overflow: hidden;     font-size: 0;     line-height: 0;     border-color:#FF9600 transparent transparent transparent;     border-style:solid;     border-width:20px;}

Example 4:

In Example 3, under IE6, you need to set the Border-style of the remaining three sides to dashed to achieve a transparent effect.

{    height:0;     width:0;     Overflow: hidden;     font-size: 0;     line-height: 0;     border-color:#FF9600 transparent transparent transparent;     border-style:solid dashed dashed dashed;     border-width:20px;}

Example 5:

The hypotenuse of the small triangle above is based on the edges of the original box, and there is another form of the small triangle, hypotenuse on the diagonal of the box.

{    height:0;     width:0;     Overflow: hidden;     font-size: 0;     line-height: 0;     border-color:#FF9600 #3366ff Transparent transparent;     border-style:solid solid dashed dashed;     border-width:;}

By preserving one of these colors, you can get a triangle on the diagonal of the hypotenuse.

Achieve rounded corners effect

Approximate rounded corners can be achieved, in fact, a very small trapezoid display out.

<!DOCTYPE HTML><HTML><Head><styletype= "Text/css">. Test{width:200px;Height:50px;}. Test. Top{width:194px;Border-color:transparent transparent #FF9600 transparent;*border-color:Pink Pink #FF9600 Pink;Border-style:dashed dashed solid dashed;Border-width:3px;Filter:chroma (Color=pink);}. Test. Center{width:200px;Height:40px;Background-color:#FF9600;}. Test. Bottom{width:194px;Height:5px;Border-color:#FF9600 Transparent Transparent transparent;*border-color:#FF9600 Pink Pink Pink;Border-style:solid dashed dashed dashed;Border-width:3px;Filter:chroma (Color=pink);}</style></Head><Body><Divclass= "Test">  <Divclass= "Top">  </Div>  <Divclass= "Center"></Div>  <Divclass= "Bottom">  </Div></Div></Body></HTML>

 

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.