HTML
CSS

floatしたときの親要素の高さを復活させる方法(clearfix)

More than 5 years have passed since last update.



style.css

#child1 {

fload: left;
}
#child2 {
fload: right;
}

.clearfix {
zoom: 1;
}
.clearfix:after {
content: ".";
display: block;
clear:both;
visibility: hidden;
}



index.html

<div class="clearfix">

<p id="child1">子要素1</p>
<p id="child2">子要素2</p>
</div>