I am facing an issue with a box that contains a heading and two sibling boxes. The heading has negative margin-top to render outside the box. Surprisingly, in all browsers except Firefox, the heading successfully pulls up its sibling boxes, but in Firefox, the boxes remain in their original position.
Upon removing the float property from the boxes, they do move up as expected. Is there a solution for this problem aside from giving the boxes a negative margin-top?
div {
background: red;
padding: 2rem;
margin-top: 8rem;
box-sizing: border-box;
}
div:after {
display: table;
content: "";
clear: both;
}
div div {
background: green;
margin: 0 0 2rem;
width: 45%;
float: left; /* Remove this and use float: right below to make it work on FF */
}
div div + div {
float: right;
}
h2 {
margin-top: -8rem;
}
<div>
<h2>
Hello
</h2>
<div>
These sibling boxes also appear outside the red box.
</div>
<div>
Except in Firefox.
</div>
</div>