I have a container div with two child divs.
The fist child is floated to the right. The second child has a top margin.
For some reason the margin on the second child is pulling down the parent container, resulting in the floated element also being pulled down.
Is there a way of making this work without nesting the second child in another div to prevent the pull down?
The elements are dynamic, so I can't just add a negative margin to the sidebar to negate the margin of the other child.
html
<div id="content">
<div id="sidebar">sidebar</div>
<div id="messages">
a message
</div>
</div>
css
body {
background-color : red;
}
#content {
background-color: blue;
}
#sidebar {
background-color: yellow;
float: right;
}
#messages {
background-color: green;
margin-top : 20px;
}