Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to apply box-shadow on all four sides?

Tags:

css

box-shadow

I'm trying to apply a box-shadow on all four sides. I could only get it on 2 sides:

like image 997
dragonfly Avatar asked Apr 09 '11 22:04

dragonfly


People also ask

How do you box shadow on all 4 sides?

box-shadow: h-shadow v-shadow blur spread color inset; In your example you're offsetting shadow by 10px vertically and horizontally. Like in other comments set first two values to 0px in order to have even shadow on all sides.

How do you get a box shadow all around?

The CSS code would be: box-shadow: 0 0 10px 5px white; That will shadow the entire DIV no matter its shape!

How do you add a shadow to only one side?

To apply a shadow effect only on one side of an element set the blur value to a positive number and set the spread value to the same size but with a negative sign. Depending on which side you want the shadow on, set the offset value as follows: Top shadow: offset-x: 0 and offset-y: -5px.


2 Answers

It's because of x and y offset. Try this:

-webkit-box-shadow: 0 0 10px #fff;         box-shadow: 0 0 10px #fff; 

edit (year later..): Made the answer more cross-browser, as requested in comments :)

btw: there are many css3 generator nowadays.. css3.me, css3maker, css3generator etc...

like image 50
Damb Avatar answered Oct 03 '22 11:10

Damb


See: http://jsfiddle.net/thirtydot/cMNX2/8/

input {     -webkit-box-shadow: 0 0 5px 2px #fff;     -moz-box-shadow: 0 0 5px 2px #fff;     box-shadow: 0 0 5px 2px #fff; } 
like image 39
thirtydot Avatar answered Oct 03 '22 12:10

thirtydot