Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I remove only the top part of a box-shadow?

Tags:

css

border

I'm using border-radius and box-shadow to make a glow around an element.

Can I remove only the top part of the box-shadow?

Live example

div {     margin-top: 25px;     color: #fff;     height: 45px;     margin-top: -5px;     z-index: -10;     padding: 26px 24px 46px;     font-weight: normal;     background: #000; /*#fff;*/     border-top: 0px solid #e5e5e5;     border-left: 1px solid #e5e5e5;     border-right: 1px solid #e5e5e5;     border-bottom: 1px solid #e5e5e5;     -webkit-border-radius: 3px;      -khtml-border-radius: 3px;        -moz-border-radius: 3px;             border-radius: 3px;     -webkit-box-shadow: rgba(200,200,200,0.7) 0px 0px 10px 0px;      -khtml-box-shadow: rgba(200,200,200,0.7) 0px 0px 10px 0px;        -moz-box-shadow: rgba(200,200,200,0.7) 0px 0px 10px 0px;             box-shadow: rgba(200,200,200,0.7) 0px 0px 10px 0px; } 

Edit: this little thingy is the problem! enter image description here

like image 396
Bakudan Avatar asked Aug 11 '11 10:08

Bakudan


People also ask

How do you make a box shadow only on top?

The simple answer is that you can't. box-shadow applies to the whole element only. You could use a different approach and use ::before in CSS to insert an 1-pixel high element into header nav and set the box-shadow on that instead.

How do you get a box shadow on the bottom only?

Use the box-shadow Property to Set the Bottom Box Shadow in CSS. We can use the box-shadow property to set the shadow only at the bottom of the box. The box-shadow property sets the shadow of the selected element.

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.


1 Answers

This works, but I'll admit to not knowing if there's a better way (or if it's possible without adding a wrapper element). Using multiple box-shadows would be a good idea, but I can't seem to make it look the same.

See: http://jsfiddle.net/thirtydot/8qEUc/3/

HTML:

<div id="bla">     <div> something </div> </div> 

CSS:

#bla {     overflow-y: hidden;     padding: 0 10px 10px 10px;     margin: 0 -10px } #bla > div {     /* the CSS from your question here */ } 
like image 138
thirtydot Avatar answered Sep 20 '22 20:09

thirtydot