Lachlan Mather Lachlan Mather - 1 month ago 7
CSS Question

CSS moving a div vertically down

Im trying to move a div inside another div down a bit, but when I use

margin-top: 10px;


It makes a white gap at the top. Heres the html:

<div id="topb">
<div id="selection">

</div>
</div>


And heres the CSS:

#topb {
background: url(images/tomato-background.jpg) no-repeat fixed;
background-size: cover;
height: 100%;
width: 101%;
margin-left: -10px;
}

#selection {
background-color: #4d4d4d;
width: 60%;
height: 500px;
margin: auto;
margin-top: 40px;
}


And heres a screenshot of the website:
image

Answer

maybe you can modify the parent element by adding padding-top:10px; instead of modifying the child.

Comments