Chapter II Background & Borders multiple Borders

Source: Internet
Author: User

2. Multiple boerders multi-border

At work we may encounter multiple borders for the outer layer of the box. such as the following effects:

Method 1:

To achieve this effect, in fact, it is very simple, using the CSS3 Box-shadow property, first look at Box-shadow properties how to use it.

Box-shadow:h-shadow v-shadow blur spread color Inset|outset/none/inherit

H-shadow horizontal offset relative to box

V-shadow Vertical offset relative to box

Blur blur radius (width of shadow)

Splread Extended radius (extended width of shadow)

Inset/outset (default) inner or outer shadow

The principle of multi-border is to add multiple shadows to the box.

As an implementation method:

box-shadow:0 0 0 10px #655, 0 0 0 15px deeppink, 0 2px 5px 15px rgba (0,0,0,.6);

Box-shadow set the three shadows, from inside to outside. The radius of the first shadow is 10px, the second shadow has a radius of 15px, and the third shadow coincides with the second shadow to set the shadow effect.

So, it is worth noting that the inside of the shadow outside will cover the outside. This is why the second setting is 15px, not 10px.

Method 2:

The Box-shadow method is good, but it is not really applied to the border, and has no effect on the size of the box. So the second method is to use the Outline property:

A outline (contour) is a line that is drawn around an element, at the periphery of the edge of the bounding rectangle, that acts as an element of prominence.

Outline:color style Width/initial/inherit

such as the effect of the code, you can write:

. Box{width:100px;height:80px;background: #655; border:2px dashed white;outline:15px solid #655; outline-offset:5px;}

  

However, the outline is only suitable for cases where there are two border, and is not applicable to rounded scenes. -_-

Scenario: Create a prototype border in slices to use Box-shadow.

Chapter II Background & Borders multiple Borders

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.