今回扱っているclearfixはこちらです。
.clearfix:after {
content: "";
clear: both;
display: block;
}
まだ理解が追いついていない人は、以下の問題を先に解いてみましょう。
初級編:clearfixを書いてみよう。
中級編:clearfixについて、きちんと説明できますか?
前回に引き続き、以下のコードを準備してください。
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>float問題</title>
<link rel="stylesheet" href="style.css">
</head>
<body>
<div class="contents">
<div class = "clearfix">
<div class="float_left"></div>
<div class="float_right"></div>
</div>
<div class="bottom_content">
</div>
</div>
</body>
</html>
.contents {
height: 1000px;
background-color: orange;
border: 1px solid black;
}
.float_left {
float: left;
background-color: blue;
height: 300px;
width: 500px;
}
.float_right {
float: right;
background-color: green;
height: 200px;
width: 500px;
}
.bottom_content {
background-color: black;
width: 100%;
height: 150px;
color: #FFF;
}
.clearfix:after {
content: "これがclearfixの正体だ!!!!!";
clear: both;
display: block;
color: white;
background-color: gray;
}