Skip to content Skip to sidebar Skip to footer

Clearing Floats Dynamically With Css

I'm trying to create a 3-column blog layout in CSS. For each new post, there will be a new div added dynamically inside of a container div. However, I'm running into trouble with c

Solution 1:

You can use the css selector nth-child to apply clear to each third element.

CSS

.box:nth-child(3n + 1) {
    clear: both;
}

Demo

How nth-child works

Note: nth-child is not supported by IE8 and less.

Post a Comment for "Clearing Floats Dynamically With Css"