If I have two 3in divs (a and b) and a 4in div (c). In a ten inch wide outer div. I want this layout
1234567890 # ruler
---------- # header
aaaccccbbb # the divs in question
But if that outer div becomes 8 inches I want this layout
12345678
--------
aaa bbb
cccc
Can that be done without JavaScript? I would do a-float:left b-float:right and c-margin:0 auto but then the elements overlap… (X is the overlap)
12345678
--------
aaXccXbb
This is the solution you want. No javascript needed, just the magic of
overflow: hiddenwhich gives the center-div respect to the flow 🙂See the effect by making the output screen wider and smaller!
CSS solution