Using jQuery 1.6.2
I have a variable number of floated divs inside a parent. The parent may have a fixed width but also may not.
I want to use jQuery to work out what number of divs are in one row, then insert a div with clear property set to both, so that the children may have variable heights and not make a mess of everything, and the parent may have a variable width.
It’s a simple thing to do either in the markup or server side scripting if you know the width of the div and if you know how many children you want in a row – but what if everything is a bit more liquid?
Is there a simple way to do this, or am I going to have to do some working out of all the widths involved and a bit of clever maths to decide where to put the clear divs?
Try this:
Sample jQuery plugin (couldn’t come up with a better plugin name):
Usage: