Forum Moderators: not2easy
.clear { clear: both } <div class="clear"></div> .parent:after {
clear: both;
content: "";
display: table
} CSS:
.parent:after {
clear: both;
content: "";
display: table
}
.graybox {
/* 99% sure you could just use background: here */
background-color: #eaecf0;
border-radius: 10px;
padding: 10px;
margin: 10px;
}
.mainleft {
float: left;
width: 50%;
}
.mainright {
float: right;
width: 50%;
}
HTML:
<div class="parent">
<div class="mainleft">
<div class="graybox">Left 1<br/><br/><br/></div>
<div class="graybox">Left 2</div>
<div class="graybox">Left 3<br/><br/></div>
<div class="graybox">Left 4</div>
<div class="graybox">Left 5</div>
</div>
<div class="mainright">
<div class="graybox">Right 1</div>
<div class="graybox">Right 2<br/><br/></div>
<div class="graybox">Right 3</div>
<div class="graybox">Right 4<br/><br/><br/><br/></div>
</div>
</div>
I'm not sure I understand what the parent-clear-after accomplishes?It clears the left and right floats that were opened after the parent div opened with
display: table; .parent:after designates that the action is to take place just before the closing </div> tag for the .parent div.