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 ;}