Upon examining the demonstration below, it is evident that in the left-column
, the top padding edge of .clearfix-using_display-table
(the yellow section) and .clearfix-using_display-table p
(the silver part) are touching. However, on the lower edge, for some unknown reason, the two edges do not touch.
Interestingly, the layout of the right-column
showcases what I envision the boxes within the left-column
should resemble.
.left-column,
.right-column {
background-color: orange;
width: 150px;
}
.left-column {
float: left;
}
.right-column {
float: right;
}
.clearfix-using_display-table,
.clearfix-using_display-block {
background-color: yellow;
width: 125px;
}
.clearfix-using_display-table p,
.clearfix-using_display-block p {
background-color: silver;
width: 100px;
margin-top: 1em;
}
.clearfix-using_display-table:after,
.clearfix-using_display-block:after {
content: " ";
clear: both;
}
.clearfix-using_display-table:after {
display: table;
}
.clearfix-using_display-block:after {
display: block;
}
<div class="wrapper">
<div class="left-column">
<h3>Table</h3>
<div class="clearfix-using_display-table">
<p>Lorem Ipsum...</p>
<p>Lorem Ipsum...</p>
</div>
</div>
<div class="right-column">
<h3>Block</h3>
<div class="clearfix-using_display-block">
<p>Lorem Ipsum...</p>
<p>Lorem Ipsum...</p>
</div>
</div>
</div>
There seems to be a connection between margin collapsing and the creation of a new BFC, but I am unsure. Can someone provide clarity on this issue?