CSS3 property Box

Source: Internet
Author: User

The CSS3 Box-shadow property allows us to easily implement a layer shadow effect. Let's take a look at this attribute in actual combat.

One. browser Compatibility for Box-shadow properties

Let's look at a browser compatibility for this property:

1, Opera: I do not know from which version of the support, I sent this article test, just updated Opera to the latest version 10.53, has supported the Box-shadow attribute.

2, Firefox through private property-moz-box-shadow support.

3, Safari and Chrome are supported by private properties-webkit-box-shadow.

All IE is not supported (do not know if IE9 has improved). Don't worry, we will introduce some hack for IE at the end of this article.

Two. Syntax for Box-shadow properties

Box-shadow has six configurable values:

Img{box-shadow: Shadow type X-axis displacement y-axis displacement shadow size shadow extended shadow color}

1. When no shadow type is set, the default is the projection effect. When set to inset, it is an inner shadow effect.

2, x-axis and y-axis displacements are not equivalent but similar to the "angle" and "position" inside Photoshop.

3, shadow size, expansion, color and Photoshop inside the same.

Three. Example analysis

Let's look at a box-shadow effect with a few examples, and start with a simple HTML test:

The following are the referenced contents:


<style type= "Text/css" >css part is written here </style>

<body>

</body>

Please note: In order to save things, the following CSS code only wrote Box-shadow, in the actual use, you should-moz-box-shadow and-webkit-shadow also write. What you need to do is simplify, copy two Box-shadow, add-moz-and-webkit-in front of them respectively.

The following are the referenced contents:
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, 10px shadow size, no expansion, color #06c

The following are the referenced contents:
img{box-shadow:0 0 10px #06C;}

The color value here is the hex value, we can also use the RGBA value, the advantage of RGBA value is that it has an alpha transparent value, you can control the transparency of the shadow.

The following are the referenced contents:
img{box-shadow:0 0 10px rgba (0, 255, 0,. 5)}

(2). Add a 20px extension to the above base

The following are the referenced contents:
img{box-shadow:0 0 10px 20px #06C;}

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

The following are the referenced contents:
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.