Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

CSS3 Question: how to have no box shadow on the top of a div?

Tags:

css

Right now when I do this:

-moz-box-shadow: 0 0 200px #00C0FF; -webkit-box-shadow: 0 0 200px #00C0FF; box-shadow: 0 0 200px #00C0FF; 

it gives a box shadow on all sides. I want it on 3 sides but not the top. How to prevent the shadow from appearing at the top?

like image 264
Laila Avatar asked Apr 14 '11 15:04

Laila


People also ask

How do I turn off shadow box in CSS?

If there is something with a shadow or border on your blog that you wish to get rid of, look for the element in the CSS section of your template. Find box-shadow or border property and change it the value to 0 or none .

How do you get rid of shadow on one side?

1) Set your shadow's horizontal alignment to the left (negative values). box-shadow: -30px 0px 10px 10px #888888; Although this way you won't have the same shadow size in the top and bottom. 2) Use a div inside a div and apply shadow to each one.

What does the css3 attribute box shadow effect?

The box-shadow property enables you to cast a drop shadow from the frame of almost any element. If a border-radius is specified on the element with a box shadow, the box shadow takes on the same rounded corners.


2 Answers

box-shadow support multiple commas which mean this is possible and can be done like below:

box-shadow: 2px 2px 3px #888, -2px 2px 3px #888; 

The first group bring shadow to the right & bottom while the second group bring shadow to the left (by using negative value) & bottom.

The complete code for cross browser support is:

-moz-box-shadow: 2px 2px 3px #888, -2px 2px 3px #888; -webkit-box-shadow: 2px 2px 3px #888, -2px 2px 3px #888; box-shadow: 2px 2px 3px #888, -2px 2px 3px #888; 
like image 193
Syafiq Freman Avatar answered Oct 07 '22 16:10

Syafiq Freman


If you can nest two divs then you should be able to use a combination of margins and overflow:hidden to 'chop off' the top shadow without losing the required effect on the other edges.

For example this mark-up:

<div class="outer">     <div class="inner">hello</div> </div> 

And this CSS

.outer {     margin-top: 200px;     overflow: hidden;    }  .inner {     width:200px;     height: 200px;     margin: 0 200px 200px 200px;     -moz-box-shadow: 0px 5px 200px #00C0FF;     -webkit-box-shadow: 0px 5px 200px #00C0FF;     box-shadow: 0px 5px 200px #00C0FF; } 

Gives this result - http://jsfiddle.net/ajcw/SLTE7/2/

like image 24
ajcw Avatar answered Oct 07 '22 15:10

ajcw