Within my Content Management System, I have custom Elements that need to be floated next to each other. Instead of adding an extra div with a class of "clear", I want to automatically insert a clear: both
at the end using CSS3.
I attempted this workaround for clear:both:
I am utilizing the +
CSS Selector to target the last float Element.
http://jsfiddle.net/xt3uhuxn/9/ (Updated with various scenarios)
.float {
float: left;
}
.float + .float::after {
visibility: hidden;
display: block;
font-size: 0;
content: " ";
clear: both;
height: 0;
}
However, the ::after content is being inserted inside the Div instead of after it. How can I achieve my goal of stopping floating when there are no more float elements?
Edit: I came up with a solution here: http://jsfiddle.net/xt3uhuxn/11/ Is this method acceptable, or should I avoid it and just set clear: none;
for every floated element on the entire site?