Use css border and cssborder

Source: Internet
Author: User

Use css border and cssborder

  • The upper and lower sides of the border display a smooth diagonal line at the junction. Using this feature, you can get a small triangle and a trapezoid by setting different width or color of the upper and lower sides of the border.
  • Adjust the width to adjust the triangle shape.

Triangle Realization

Example 1:

 

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

Example 2:

When the height and width are set to 0, a diagonal line is displayed.

 

# Test2 {height: 0; width: 0; overflow: hidden;/* overflow, font-size, line-height */font-size: 0;/* is set here because, although the width and height are 0, in IE6, the default */line-height: 0;/* font size and row height are displayed, as a result, the box is rendered with an extended long rectangle */border-color: # FF9600 # 3366ff # 12ad2a # f0eb7a; border-style: solid; border-width: 20px ;}

Example 3:

In Example 2, we can see that there are four triangles. If you keep only one color for the four colors, set the remaining three colors to transparent or the same as the background color, then a triangle is formed.

 

#test3 {    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, in IE6, you need to set the border-style on the remaining three sides to dashed to achieve transparent effect.

#test4 {    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 oblique edges of the preceding small triangle depend on the sides of the original box, and there is another form of small triangle, with the oblique edges on the diagonal lines of the box.

 

#test5 {    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:40px 40px 0 0 ;}

Retain one of the colors to get the triangle with the oblique side on the diagonal line.

 

Achieve rounded Corner Effect

An Approximate rounded corner can be achieved, but it is actually displayed as a very small trapezoid.

 

<!DOCTYPE HTML>

 

Related Article

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.