【CSS】clearfixについて
概要
floatプロパティによって浮いた要素の回り込みを解除できる(バリアを張るイメージ)
具体例
<div class="clearfix">
<div class="box1"></div>
<div class="box2"></div>
</div>
<div class="box3"></div>
.clearfix::after{
content: "";
display: block;
clear: both;
}
.box1{
background-color: red;
width: 200px;
height: 200px;
float: left;
}
.box2{
background-color: green;
width: 200px;
height: 200px;
float: left;
}
.box3{
background-color: yellow;
width: 200px;
height: 200px;
}
実行
.clearfix::after
clearfixというクラス名を付けた要素の直後
content:"";
contentプロパティで任意の文字を挿入
display: block;
clearfixを付けた要素の直後に要素を作る
clear: both;
float解除
参考
Author And Source
この問題について(【CSS】clearfixについて), 我々は、より多くの情報をここで見つけました https://qiita.com/komekami0131/items/eb048d5cab5aebc0fb72著者帰属:元の著者の情報は、元のURLに含まれています。著作権は原作者に属する。
Content is automatically searched and collected through network algorithms . If there is a violation . Please contact us . We will adjust (correct author information ,or delete content ) as soon as possible .