I'm having a strange problem positioning a set of divs inside another div. I think it will be best to describe it with an image:
Inside the black (#box) div there are two divs (.a, .b) that have to positioned in the same place. What I'm trying to achieve is pictured in the first image, second one is the effect I get. It looks like if the divs were floated without clearing or something, which is obviously not the case. Any ideas would be welcome!
Here's the code for this sample:
CSS:
#box {
background-color: #000;
position: relative;
padding: 10px;
width: 220px;
}
.a {
width: 210px;
position: absolute;
top: 10px;
left: 10px;
background-color: #fff;
padding: 5px;
}
.b {
width: 210px;
position: absolute;
top: 10px;
left: 10px;
background-color: red;
padding: 5px;
}
#after {
background-color: yellow;
padding: 10px;
width: 220px;
}
HTML:
<div id="box">
<div class="a">Lorem</div>
<div class="b">Lorem</div>
</div>
<div id="after">Hello world</div>
question from:
https://stackoverflow.com/questions/1137517/how-to-position-absolute-inside-a-div 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…