Two column layouts are quite common and until now I implement it as outlined in this question: Right div is floating right and has e.g. width 200px, left div gets a margin-right of 200px.
Therefore, to remove the right div, you have to remove it from HTML and – that’s the unpleasant part – remove the margin-right from the left div.
I’m wondering whether the same can be obtained without making any such changes necessary in the CSS.
Here is the test page: http://pastie.org/1669826
The goal:
div#right present in HTML: div#right not present in HTML:
+---------------------+ +---------------------+
| | | |
+---------------------+ +---------------------+
+----------------+ +--+ +---------------------+
| | | | | |
| | +--+ | |
| | | |
| | | |
+----------------+ +---------------------+
+---------------------+ +---------------------+
| | | |
+---------------------+ +---------------------+
A partial solution which work on FF and WebKit but not on IE: Give div#right a height of 100% and move it inside div#left.
Looking forward to your ideas!
Assuming equal height columns are desirable, this is a nice method.
Firstly, make sure you add a doctype as the first line:
Otherwise you get Quirks Mode = bad, bad, bad.
Live Demo
Live Demo (exact same code with right div removed)
This will work in every modern browser and IE8. It won’t work in IE7 without some crazy hacks.
Do you need IE7 support?