Using Box-Shadow with CSS3

I showed in a previous post how to use text-shadow with CSS3. Now it’s time to move on to something that’s just about as exciting, using Box-Shadow with CSS3. Throw it on a div, on a table, on an image.. anything goes! Of course it doesn’t work in every browser, but then again not much I talk about on this site does!
Check out the demo to see some examples and then keep reading to find out how to use Box-Shadow.
View Demo
Below are the examples from the demo page, with the code below it which made the shadow. For each shadow, you need to declare the dimensions for -webkit-box-shadow: and -moz-box-shadow:, which takes care of any browser that supports the box-shadow at this point.
The three numbers are similar to using text-shadow with CSS3, the first number is how far right the shadow is from the “box”, the next number is how far below, and the final number is the amount of blur for the shadow. Finally, you declare the color of the shadow.
You’ll see on a couple of them I used the awesome border-radius to show how the shadow wraps around a rounded corner. If you need a refresher on the border-radius declarations, look here. If you want to check out some examples and code of text-shadow, look here.
{
-webkit-box-shadow: 2px 2px 4px #000;
-moz-box-shadow: 2px 2px 4px #000
}
{
-webkit-box-shadow: 6px 6px 6px #444;
-moz-box-shadow: 6px 6px 6px #444
}
{
-webkit-box-shadow: 4px 4px 6px #F6C;
-moz-box-shadow:4px 4px 6px #F6C
}
{
-webkit-box-shadow: 6px 6px 10px #000;
-moz-box-shadow: 6px 6px 10px #000;
-webkit-border-radius:12px;
-moz-border-radius:12px;
border:15px solid #F90
}
{
-webkit-box-shadow: 6px 6px 10px #990;
-webkit-border-radius:12px;
-moz-box-shadow: 6px 6px 10px #990;
-moz-border-radius:12px;
border:12px solid #000
}
{
-webkit-box-shadow: 0px 0px 20px #6F0;
-moz-box-shadow: 0px 0px 20px #6F0
}
{
-webkit-box-shadow: 0px 0px 30px #000;
-moz-box-shadow: 0px 0px 30px #000
}


November 24th, 2009 at 4:33 am
[...] Using Box-Shadow with CSS3 | WebDesign & Such [...]
November 24th, 2009 at 12:01 pm
[...] Using Box-Shadow with CSS3 | WebDesign & Such [...]
November 25th, 2009 at 9:08 am
[...] Using Box-Shadow with CSS3 | WebDesign & Such [...]
November 25th, 2009 at 12:28 pm
[...] Using Box-Shadow with CSS3 | WebDesign & Such [...]
November 25th, 2009 at 3:38 pm
[...] Using Box-Shadow with CSS3 | WebDesign & Such [...]
December 2nd, 2009 at 2:00 am
[...] Using Box-Shadow with CSS3 | WebDesign & Such [...]
December 13th, 2009 at 1:47 am
[...] Using Box-Shadow with CSS3 | WebDesign & Such [...]
December 26th, 2009 at 12:57 am
[...] Using Box-Shadow with CSS3 | WebDesign & Such [...]