0

I am working on a product page layout that has two columns with various height items. I am trying to avoid nesting the items in two column containers, so that I can have optimal order of elements on small screens that go to one column.

The problem I am running into is that sometimes the second block (floated left) is longer than the first block (floated right), and sometimes the opposite is true. The problem occurs when the third block is given clear: left to make sure it's as far right as it can go, the fourth block will not go above the top of the third block.

floated layout with gap

Here is a CodePen with the code: http://codepen.io/anon/pen/jAQdEK?editors=1100#anon-login

Travis L
  • 683
  • 2
  • 7
  • 12

1 Answers1

0

What you want to do looks like a layout table to me. Using display types table, table-row and table-cell might be an easy and solid solution for that. See:

http://codepen.io/wortwart/pen/grQqzv

wortwart
  • 3,139
  • 27
  • 31
  • Not exactly what I'm looking for. I would like the blocks to only be as tall as the content in them, rather than share the height of the taller block next to them as in your example. – Travis L Aug 09 '16 at 15:08
  • Sorry, I misread your requirements. Maybe flexbox is the right thing for your problem if you can afford to ignore IE <= 9. – wortwart Aug 09 '16 at 15:27