I have a CMS with custom Elements, some of them shall be floated with each other. My idea is to use CSS3 to automatic insert a clear: both
at the end of them without add a extra div with class="clear".
I try to this clear:both work around: https://stackoverflow.com/a/6681806/2481955
And use the +
CSS Selector to select the last float-Element.
http://jsfiddle.net/xt3uhuxn/9/ (Updated with different cases)
.float {
float: left;
}
.float + .float::after {
visibility: hidden;
display: block;
font-size: 0;
content: " ";
clear: both;
height: 0;
}
But as you can see the ::after-Content is inserted into the Div, not after the div. What could I do to archive my goal (stop floating if no mor float elements are coming)
Edit: I found an approach: http://jsfiddle.net/xt3uhuxn/11/ The question is, is this a no-go or can I do it like this for the hole site and just set for every element that get floated: clear: none;
?