How can I make box-shadow appear above a div?
It's #top
and its box-shadow
that you want to appear on top, so give that position: relative
instead of giving position: relative
to #middle
. There's no need for z-index: 0
.
http://jsfiddle.net/thirtydot/QqME6/1/
#top {
width: 100%;
height: 100px;
box-shadow: 3px 3px 3px #333;
background-color: blue;
position: relative;
}
#middle {
width: 100%;
height: 200px;
background-color: orange;
}
#innerMiddle {
width: 200px;
height: 200px;
margin: 0 auto;
background-color: green;
}
<div id="top">
</div>
<div id="middle">
<div id="innerMiddle">
</div>
</div>
Change your CSS to:
#top {
width: 100%;
height: 100px;
box-shadow: 3px 3px 3px #333;
background-color: blue;
position:relative;
z-index:1;
}
#middle {
width: 100%;
height: 200px;
z-index: 0;
position: relative;
background-color: orange;
}
<div id="top">
</div>
<div id="middle">
<div id="innerMiddle">
</div>
</div>