I have a responsive layout consisting of a bunch of elements. Here is a very simplified version of the code:
HTML:
<div class="parent"> <div class="header"></div> <div class="child"></div> <div class="child"></div> <div class="child"></div> <div class="child"></div> <div class="child"></div> <div class="child"></div> <div class="child"></div> </div>
CSS
.parent { background: red; display:inline-block; } .child { background: green; width:100px; height:100px; float:left; } .header { background: yellow; width:100%; height:30px; }
Jsfiddle
I am trying to ensure that the title (yellow box) is the same width as the child divs (green fields). And it works well when the layout is displayed first, here is a screenshot from JSFiddle 
But when the screen size becomes narrower, the title does not compress correctly, here is a screenshot for a smaller area:

I spent several hours trying to figure it out, but I could not. Part of the problem is that I don’t know in advance how many green boxes there will be, since they are dynamically displayed by .NET.
Update 1
The fact that packing green boxes is desirable, I am trying to ensure that the yellow box is the same width as the combined width of the green boxes. Desired Result:

source share