Reputation: 59
I have a div that stand for the logo, and I have another div that stand for a slide show. The slide show div is under the logo div, and I want it to be under the it and behind it.
This is what I have:
HTML
<div id="site-container">
<div id="header-container">
<div id="logo"></div>
</div>
<div id="slide"></div>
</div>
CSS
#logo {
background:url(img/logo.png) no-repeat left top;
width:259px;
height:147px;
float:left;
}
#slide {
background:url(img/slide.png) no-repeat left top;
width:776px;
height:437px;
float:left;
}
I tried to use z position, but it turns to be something I dont want it to. Any why to make the logo div be a top layer without moving its correct position?
Upvotes: 2
Views: 43878
Reputation: 7159
The corrected css is,
#logo {
background:url(img/logo.png) no-repeat left top;
width:259px;
height:147px;
float:left;
position:absolute;
z-index:1000;
}
#slide {
background:url(img/slide.png) no-repeat left top;
width:776px;
height:437px;
float:left;
position:relative;
z-index:500;
}
The position of the slide div is set as relative and logo div is set as absolute. So the logo is placed within the slide.
The value of z-index attribute decides which one is under.
Upvotes: 3
Reputation: 1468
Try the following: CSS
#Behind{
width:100%;
background-color:orange;
position: absolute;
z-index: -1;
padding:50px;
}
#TopOne{
position: absolute;
top:70px;
left:50px;
background-color:wheat;
padding:20px;
}
and the htm simply
<div id="Behind"></div>
<div id="TopOne">This is Just Testing :)</div>
This is the JSFiddle link also JSFiddle
Upvotes: 4
Reputation: 59
i used these:
#logo {
background:url(img/logo.png) no-repeat left top;
width:259px;
height:147px;
float:left;
position:absolute;
z-index:1;
}
#slide {
background:url(img/slide.png) no-repeat left top;
width:776px;
height:437px;
float:left;
position:relative;
}
and the slide show is now when it should be but the logo div float to the right while i need it to stay at the left side... sorry if you dont understand not sure about my english grammer lol
Upvotes: 1
Reputation: 101
You are missing quite a few things to do that.
z-index will tell you what comes on top.
position needs to be absolute
And you may what to play with the margins...
Upvotes: 2
Reputation: 15749
If you want it over top of the div, you have to use z-index
. You have to convert your #logo
and #slide
to have a position
attribute and z-index
should be applied to the div whose position you want to move up or down.
Upvotes: 4