tags:

views:

59

answers:

6

how can we make one div in front on another div?

A: 

Use the z-index property

img
{
position:absolute;
left:0px;
top:0px;
z-index:-1;
}

or

Use the position property

h2
{
position:absolute;
left:100px;
top:150px;
}
Brian R. Bondy
oh wow, that was quite a lot of posts at the same time, all pretty much saying the same thing.
quoo
+2  A: 

You can do that with CSS absolute positioning and z-index.

See Demo Here

<style type="text/css">
div { border:1px solid black; }
.infront {
background-color:#ff9900;
width:100px;
height: 100px;
position: relative;
top: 10;
left:80;
z-index: 2;
}
.behind {
background-color:#eeeeee;
width:100px;
height: 100px;
position: relative;
top: -60;
left:35;
z-index: 1;
}
</style>
<div class="infront">
In front
</div>
<div class="behind">
Behind
</div>
Sarfraz
A: 

Use absolute positioning in CSS:

#divbox {
 position: absolute;
 top: 0;
 right: 0;
}

There's also great article regarding positioning of elements in CSS:

http://www.barelyfitz.com/screencast/html-training/css/positioning/

Ondrej Slinták
A: 

If you mean one div OVER another div, you probably need to look for the z-index

Frank
A: 

Set the divs' z-index

quoo
A: 

You should make one div with position:relative or position:absolute and add a value of z-index, e.g.:

<!-- Assuming that this is the only content of the <body> element -->
<div style="position:absolute; z-index:10; top:10px; height:40px;"></div>
<div style="height:500px;"></div>

To distinguish, add a solid border to the DIVs.

Refer to:

Dor