Thursday 15 September 2011

javascript - Organize container content by container height -


I have a site that has 2 containers in which each has a bunch of related material, what is the content in the container Its organization is important, but as much as possible is not as important as the height of the containers.

Code:
  & lt; Button & gt; Click to add more boxes & lt; / Button & gt; & Lt; Div id = "wrapper" align = "center" & gt; & Lt; Div id = "container1" & gt; & Lt; Div class = "box" & gt; & Lt; / Div & gt; & Lt; Div class = "box" & gt; & Lt; / Div & gt; & Lt; Div class = "box" & gt; & Lt; / Div & gt; & Lt; / Div & gt; & Lt; Div id = "container2" & gt; & Lt; Div class = "box" & gt; & Lt; / Div & gt; & Lt; Div class = "box" & gt; & Lt; / Div & gt; & Lt; Div class = "box" & gt; & Lt; / Div & gt; & Lt; Div class = "box" & gt; & Lt; / Div & gt; & Lt; / Div & gt; & Lt; / Div & gt;  


Question:

After adding more items, you will see that only once a container will have a lot of content Compared to the second, but it happens

When this happens, I want to take the left over items in a large container, and would like to distribute the container in such a way that the height of each container As close as possible to

How can I go about doing this?

A standard algorithm subset sum problem to resolve it.

The problem says

  You have n integers, divide an integer into two sets, such as. Set1 | | - | Set 2 The minimum is where. Set (i) | Ith represents the sum of elements in the set.   

I think you have a similar problem here. Assume your containers two sets and the height of each box as an integer that is being kept in that set. Problems We need to divide the integer in such a way that the height of two containers remains minimal.

Relevant Links:

- Good One

No comments:

Post a Comment