style.css
setup.css
index.html
/* Setup styles are in the other file. */
aside {
background-color: gold;
float: left;
margin-right: 10px;
padding: 10px;
width: 100px;
}
div:nth-child(2) aside {
float: right;
margin-left: 10px;
margin-right: initial;
}
div:after { /* This is the “clearfix”. */
clear: both;
content: '';
display: block;
}
body {
font-family: sans-serif;
padding: 20px;
}
div {
background-color: deepskyblue;
border-top: solid black 4px;
padding: 10px;
}
div:not(:first-child) { margin-top: 20px; }
<!DOCTYPE html>
<html>
<head>
<title>Float clearfix</title>
<link href="/assets/styles/reset.css" rel="stylesheet">
<link href="setup.css" rel="stylesheet">
<link href="style.css" rel="stylesheet">
</head>
<body>
<section>
<div>
<aside>
<p>This is an aside element.</p>
</aside>
<p>This is some text.</p>
</div>
<div>
<aside>
<p>And another aside here too, with a lot more text in it.</p>
</aside>
<p>And some more.</p>
</div>
<div>
<p>And a third one, too.</p>
</div>
</section>
</body>
</html>