How to make shadow effect with CSS, compatible with IE、Firefox、Google Chrome

The code works well in Firefox、Google Chrome.

-moz-box-shadow: 0 0 30px #CCC;
-webkit-box-shadow: 0 0 30px #CCC;
box-shadow: 0 0 30px #CCC;

An example:

you should see shadow around this box if you are using Firefox or Google Chrome

 
-moz-box-shadow: 0 0 30px #CCC;  is compatible with Firefox 3.6
-webkit-box-shadow: 0 0 30px; is compatible with Google Chrome 6.0

box-shadow may be compatible with some other browsers, but it has no effect in IE8、Firefox 3.6、Google Chrome 6.0。

The values refer to:

1,The horizontal offset of the shadow.

If positive, the shadow on the right of box; otherwise, on the left of the box;

2,The vertical offset of the shadow

If positive, the shadow on the above of box; otherwise, on the below of the box;

3,The blur radius
If zero, the shadow will be sharp; the higher, the more blur;

4,Color

If with inset, the shadow will be in the inner of the box; i.e.:

-moz-box-shadow: inset 0 0 30px #CCC;
-webkit-box-shadow: inset 0 0 30px #CCC;
box-shadow: inset 0 0 30px #CCC;

If another value is set, the shadow can be smaller than the original one; i.e.:
-moz-box-shadow: 0px 20px 10px -10px #888;

All the above has no effect in IE8. It’s said that those works on the browsers compatible with CSS3.

In IE, the below can be used:

filter:progid:DXImageTransform.Microsoft.Blur(PixelRadius=’8′, MakeShadow=’true’,

ShadowOpacity=0.20′);

or

filter: progid:DXImageTransform.Microsoft.Shadow(color=’#969696′, Direction=135, Strength=3)

I like the first one. using two <div> models, the below one makes shadow effect, the top one is just as normal. The different shadow effects can be got by adjusting the relative position of two <div> model.

Leave a Reply

Your email address will not be published. Required fields are marked *