I have the following layout. I've set my CSS so that the p
element overlaps the first div
.
#wrapper {
width: 600px;
margin: 0 auto;
}
.div-01 {
background: red;
height: 400px;
}
.div-02 {
background: green;
height: 200px;
}
p {
background: blue;
color: #fff;
margin: 0 100px;
padding: 100px;
position: relative;
bottom: 100px;
}
<div id="wrapper">
<div class="div-01"></div>
<p>Hello world</p>
<div class="div-02"></div>
</div>
But I also want it so that there is no gap before the green div
, notice here that the green div
is acting like the position of the p
hasn't been modified.
I understand that this is normal behaviour, but is there any way to get the green div
to appear straight after the p
?
EDIT:
Sorry, I should have mentioned that I'd like it so that all elements after the p
act as though the p
hasn't been moved with relative positioning exactly, but as though it's natural position is as though it was overlapping the blue div
So basically no gaps in between any elements that follow the p
I also can't use absolute
positioning, because it's unclear how tall any of the elements will be in the real thing