White space appears when using margin-top

yotube
0

Issue

I am attempting to use margin-top push a container down relative to its parent container. However, when trying to do so, a white gap is appearing between the parent div and the preceeding div (see screenshots). I am wondering if anyone has a solutionenter image description here for this.

enter image description here

enter image description here


Solution

Use padding, not margin if the issue is that the background isn't getting filled in. This applies to the parent div, not the child:

http://jsfiddle.net/tmd4thpa/

.container {
background: purple;
padding:20px;
}
.div {
height:500px;
background: red;
}
<div class="container">
<div class="div"></div>
</div>


Answered By - austinthedeveloper
Tags

Post a Comment

0Comments
Post a Comment (0)

#buttons=(Accept !) #days=(20)

Our website uses cookies to enhance your experience. Learn More
Accept !
To Top