How to use the box-shadow (layer shadow) attribute in css3

Source: Internet
Author: User

The box-shadow attribute of css3 allows us to easily implement layer shadow effects. Let's take a closer look at this property.

First, let's take a look at the browser compatibility of this attribute:

    • Opera: I don't know which version is supported. I'm posting this article.ArticleDuring the test, opera is updated to the latest version 10.53, and the box-shadow attribute is supported.
    • Firefox supports private attributes-moz-box-Shadow.
    • Safari and chrome are supported by private properties-WebKit-box-Shadow.

All IE does not support (I wonder if ie9 has improved ). Don't worry, we will introduce some hack for IE at the end of the article.

Ii. syntax of the box-shadow attribute

Box-shadow has six configurable values:

IMG {box-Shadow: Shadow Type X axis displacement Y axis displacement shadow size shadow extended shadow color}

    • If the shadow type is not set, the projection effect is used by default. When it is set to inset, It is the inner shadow effect.
    • The X axis and Y axis displacement are not the same but similar to the "angle" and "position in Photoshop.
    • The shadow size, expansion, color, and Photoshop are all the same.

Iii. instance resolution

Let's take a look at the effects of a box-shadow through several examples. First, we can get a simple HTML for testing:

 
<HTML> <Style type = "text/CSS"> the CSS part is written here </style>
</Head>
<Body>

</Body>
</Html>

Note: The following CSSCodeOnly box-shadow is written. In actual use, you should also write-moz-box-shadow and-WebKit-Shadow. Copy two boxes-shadow and add-moz-and-WebKit-before them -.

 
IMG {-moz-box-Shadow: 2px 2px 10px # 06c;-WebKit-box-Shadow: 2px 2px 10px # 06c; box-Shadow: 2px 2px 10px # 06c ;}

 

 (1) projection, no displacement, 10 PX shadow size, no expansion, color # 06c

 
IMG {box-Shadow: 0 0 10px # 06c ;}

Here, the color value is the hex value. We can also use the rgba value. The advantage of the rgba value is that it has an Alpha transparency value while you can control the transparency of the shadow.

 
IMG {box-Shadow: 0 0 10px rgba (0,255, 0,. 5 )}

(2) Add 20 PX extension to the above

IMG {box-Shadow: 0 0 10px 20px # 06c ;}

(3) Inner Shadow, no displacement, 10 PX size, no expansion, color # 06c

 
IMG {box-Shadow: Inset 0 0 10px # 06c ;}

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.