Can CSS pseudo elements :after or :before be used to clear floats between elements? If not, what other method can be used to clear floats between <div class="float">
and <section class="inner">
?
The HTML and CSS structure is as follows:
* {
margin: 0;
padding: 0;
}
*, *:before, *:after {
box-sizing: border-box;
}
section.wrap {
width: 100%;
}
section.wrap:after {
content: '';
display: block;
clear: both;
}
div {
width: 33.33%;
height: 40px;
background-color: powderblue;
float: left;
border-top: solid 0px white;
border-right: solid 5px white;
border-bottom: solid 5px white;
border-left: solid 0px white;
}
div:nth-of-type(3n + 3) {
border-right: 0;
}
<section class="wrap">
<div class="float"></div>
<div class="float"></div>
<div class="float"></div>
<div class="float"></div>
<div class="float"></div>
<div class="float"></div>
<div class="float"></div>
<div class="float"></div>
<div class="float"></div>
<div class="float"></div>
<!-- CLEAR FLOAT HERE -->
<section class="inner">
Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet. Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet.
</section>
</section>