I'm having a problem getting div
elements to stack on top of each other vertically. I have a mainwrapper
and 2 div
elements inside them that I need to be stacked. But whenever I give the first inner div
position: absolute
and then right: 0
or even float: right
, it goes into the second div
. Is there any way around this?
<div class="wrapper">
<div class="test1"></div>
<div class="test2">
<div class="test3"></div>
</div>
</div>
CSS:
.wrapper {
width: 605px;
margin: 0 auto;
position: relative;
background: transparent;
border: 1px solid black;
height: 240px;
}
.test1 {
border: 1px solid black;
width: 200px;
height: 30px;
display: block;
position: absolute;
right: 0;
}
.test2 {
border: 1px solid red;
width: 600px;
height: 200px;
display: block;
position: absolute;
}
.test3 {
border: 1px solid black;
width: 100px;
height: 20px;
position: absolute;
bottom: 20px;
right: 0;
}
Here is my jsfiddle.