CSS3 box-shadow on left and right sides only
It is possible to have inset shadows on both left and right sides of a block. It is a matter of showing only one side of the box-shadow at a time, and so you need two box-shadows (one for each side of the block you wish to have shadows, and we can put both CSS codes in the same property).
Here is an example that should be compatible with Firefox, Chrome and Opera.
box { -moz-box-shadow: inset 5px 0 5px -5px #333, inset -5px 0 5px -5px #333; -webkit-box-shadow: inset 5px 0 5px -5px #333, inset -5px 0 5px -5px #333; box-shadow: inset 5px 0 5px -5px #333, inset -5px 0 5px -5px #333; } |
Here is the result:
Inspired from Playing with CSS3 box shadow [demente-design.com]

























jim said
June 27 2011 @ 9:25 AM
nice, thanks...
Kenneth John Odle said
December 17 2011 @ 8:47 PM
Thank you for this. I have been creating multiple stylesheets for my main web site and I couldn't figure out how to get red inset shadows for the Fourth of July theme. This worked perfectly. Thanks!
Aakil said
January 24 2012 @ 7:01 PM
Used this without the inset.
Thanks for the writeup!
Fractal said
February 14 2012 @ 3:50 PM
If only it works in all browsers...
Santosh said
February 23 2012 @ 8:41 AM
it is very nice but, i want apply it out site of box how can i do?
Curtis said
March 6 2012 @ 10:16 AM
I would also like to apply this to the outside (sides only) of the box. Is this possible?
@cartus said
April 12 2012 @ 5:28 PM
Curtis,
Just delete the inset shit
..
box-shadow:
5px 0 5px -5px #333,
Aaron said
June 13 2012 @ 4:05 PM
Yes Curtis, just don't put "inset" in your code.
Damon said
June 20 2012 @ 9:56 AM
@Santosh & @Curtis -
To apply this to the outside of a box, simply remove all of the instances of "inset" in the code.
Thanks for the code!
nK0de said
September 25 2012 @ 4:03 AM
Nice snippet! Simple and effective! Thanks
jhunalie said
October 2 2012 @ 7:55 AM
thanks so much for this!
dzulfikar said
November 4 2012 @ 10:39 PM
finally I found this trick, using comma