I have this div that extends downwards beyond the page height and the white spacing under the div disappears, how do I add the white spacing back?
div {
background-color: grey;
position: relative;
top: 136px;
}
<div>
<p>Lorem Ipsum<br>Lorem Ipsum<br>Lorem Ipsum<br>Lorem Ipsum<br>Lorem Ipsum<br>Lorem Ipsum<br>Lorem Ipsum<br>Lorem Ipsum<br>Lorem Ipsum<br>Lorem Ipsum<br>Lorem Ipsum<br>Lorem Ipsum<br>Lorem Ipsum<br>Lorem Ipsum</p>
</div>
Just use margin-top
instead of top
, that way that distance is added at the top instead of the div
just being moved by that value, in relation to its original position in the document flow (which doesn't extend the height of the parent element).
div {
background-color: grey;
position: relative;
margin-top: 136px;
}
<div>
<p>Lorem Ipsum<br>Lorem Ipsum<br>Lorem Ipsum<br>Lorem Ipsum<br>Lorem Ipsum<br>Lorem Ipsum<br>Lorem Ipsum<br>Lorem Ipsum<br>Lorem Ipsum<br>Lorem Ipsum<br>Lorem Ipsum<br>Lorem Ipsum<br>Lorem Ipsum<br>Lorem Ipsum</p>
</div>
Collected from the Internet
Please contact [email protected] to delete if infringement.
Comments