Here is the completed CSS the article uses. It is well worth reading the entire article, as the author goes step by step into what you need to make this work.
I used 400px as the switch between columns and a vertical layout in this case, because jsfiddle panes trend pretty small. Mess with the size of that window and you'll see the columns nicely rearrange themselves, including stretching to full height when they need to be columns so their background colors don't get cut off part-way down the page. No crazy padding/margin hacks that crash into later tags on the page, and no tossing of 5% of your visitors to the wolves.
Yes.
Here is the completed CSS the article uses. It is well worth reading the entire article, as the author goes step by step into what you need to make this work.
This isn't the only method for doing it, but this is probably the most elegant method I've encountered.
There is another site that is done completely in this manner, viewing the source will allow you to see how they did it.
You could use CSS tables, like so:
You can do this easily with the following JavaScript:
Flexbox
If you are reading this in late 2013, you have flexbox at your disposal. Assuming this layout:
With flexbox, equal height columns is just one declaration:
Browser support: http://caniuse.com/flexbox; demo: http://jsfiddle.net/7L7rS/
Table layout
If you still need to support IE 8 or 9, then you have to use table layout:
Demo: http://jsfiddle.net/UT7ZD/
Responsive answer:
CSS flexbox is cute, but cutting out IE9 users today is a little insane. On our properties as of Aug 1 2015:
3% IE9
2% IE8
Cutting those out is showing 5% a broken page? Crazy.
Using a media query the way Bootstrap does goes back to IE8 as does
display: table/table-cell
. So:http://jsfiddle.net/b9chris/bu6Lejw6/
HTML
CSS
I used 400px as the switch between columns and a vertical layout in this case, because jsfiddle panes trend pretty small. Mess with the size of that window and you'll see the columns nicely rearrange themselves, including stretching to full height when they need to be columns so their background colors don't get cut off part-way down the page. No crazy padding/margin hacks that crash into later tags on the page, and no tossing of 5% of your visitors to the wolves.
Give
overflow: hidden
to the container and large (and equal) negative margin and positive padding to columns. Note that this method has some problems, e.g. anchor links won't work within your layout.Markup
CSS
The Result