I have a fixed positioned div on the top of the page. (e.g. Facebook) And an relative positioned div in the page. When I scroll down, relative div is passing over fixed div. I want it to pass under fixed div. Is there any idea to handle this ?
#navcontainer
{
position:fixed;
}
.city
{
position:relative;
float:left;
}
.city .text
{
position:absolute;
top:100px;
left:15px;
}
In this css I have a city div and absolute text is sitting on the image which is in relative div (.city)
Hi I think you should do this:
css
#navcontainer
{
position:fixed;
background:red;
left:0;
right:0;
top:0;
height:100px;
z-index:3;
}
.city
{
position:relative;
background:green;
left:0;
right:0;
padding:10px;
top:100px;
z-index:2;
}
.city .text
{
padding:10px;
background:yellow;
}
HTML
<div id="navcontainer">This is navigation</div>
<div class="city">
<div class="text">here text <br />here text <br />here text <br />here text <br />here text <br />here text <br />here text <br />here text <br />here text <br />here text <br />here text <br />here text <br />here text <br />here text <br />here text <br />here text <br />here text <br />here text <br />here text <br />here text <br />here text <br />here text <br />here text <br />here text <br />here text <br />here text <br />here text <br />here text <br />here text <br />here text <br />here text <br />here text <br />here text <br />here text <br />here text <br />here text <br />here text <br />here text <br />here text <br />here text <br />here text <br />here text <br />here text <br />here text <br />here text <br />here text <br />here text <br />here text <br /></div>
</div>
Live demo http://jsfiddle.net/xLnKN/1/
I think what you are looking for is the CSS property z-index
. See here for documentation: http://reference.sitepoint.com/css/z-index
I threw together a small example showing how to use it with your CSS: http://jsfiddle.net/B63Km/
The basic idea is the higher the z-index, the closer the element is to you.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With