I have three left floated containers per row on my website with 33% width and I would like to provide the first of the new row with the attribute clear: both, because there are 12 containers.
Is there an easier way to determine the selector? Here is my approach:
.container:nth-of-type(4), .container:nth-of-type(7), .container:nth-of-type(10) {
clear: both;
}
I've also tried something with "3n", but it I didn't work for me...
I know it doesn't work... but is there something like this?
.container:nth-of-type(4,7,10) {
clear: both;
}
Or are there better approaches? Every answer is appreciated, thanks.
.container {
width: calc((100% - 120px)/3); /* calc because of the padding */
padding: 0px 20px;
height: 300px;
background-color: red;
float: left;
display: block;
}
.container:nth-of-child(4), .container:nth-of-child(7), .container:nth-of-child(10) {
clear: both;
}
<div class="container"></div>
<div class="container"></div>
<div class="container"></div>
<div class="container"></div>
<div class="container"></div>
<div class="container"></div>
<div class="container"></div>
<div class="container"></div>
<div class="container"></div>
<div class="container"></div>
<div class="container"></div>
<div class="container"></div>