CSS3 creates multiple borders

Source: Internet
Author: User

Yes, we know: We can set its width for border. The width of this border can be 5px, but 10px, 20px, or random value.

However, have you ever imagined that you can set a color for every 1px border? What is this concept? That is to say, if you set a 10px border for an element, you can set 10 colors for the 10px border area. Every 1px is a heavy weight (group ). DEMO: css3 border-colors multi-group border color details

Well, let's review how to set the border size for the element (code block 1 ):

 

 

The above Code defines a 6px border for a div element whose className is test. Of course, this is a rectangle with four sides.

As a result, the CSS code can be refined to (code block 2 ):

 

 

After the code is refined, we can set the color for the four sides of the rectangle. Whether the color is set to the same or different depends on your needs.

Run the refined code (of course you can change the color of each edge) to see a rectangle with a 6 PX black border. Well, this is what we expected.

However, now we can split the 6 PX border into 6 groups, each of which is 1 group, so each border can be set to a maximum of 6 different colors.

How? Check it out (code block 3 ):

 

. Test {

Border-width: 6px;

Border-style: solid;

Border-top-colors: #000 # fff #999 # aaa # ccc # eee;

Border-right-colors: #000 # fff #999 # aaa # ccc # eee;

Border-bottom-colors: #000 # fff #999 # aaa # ccc # eee;

Border-left-colors: #000 # fff #999 # aaa # ccc # eee;

}

  • 2 pages in total:
  • Previous Page
  • 1
  • 2
  • Next Page

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.