Overcoming the challenge of positioning and determining the width of .bottom
presents the primary obstacle in creating a cross-browser CSS solution.
Alternatives
1. Floats
By floating only the left column, flexible widths can be achieved as demonstrated by @joeellis. Applying overflow:hidden
to the right column helps in this process.
However, achieving the correct position of .bottom
proves difficult due to limitations with floated columns of equal but variable height. Placing the absolutely positioned .bottom
element within the right column div with 100% width does not guarantee it will align at the bottom of the container if the right column's height is shorter than the left column.
2. HTML tables and CSS tables
Setting the left cell's width to 1px and leaving the right cell width unspecified can result in flexible widths for both cells that expand to fit the content. Any excess space will be added solely to the right cell.
Incorporating .bottom
within the right table cell poses challenges, especially in Firefox. Relative positioning does not have the desired effect within a table cell in Firefox, making absolute positioning and 100% width problematic.
If .bottom
is treated as a separate table cell within the right column, achieving correct heights for both cells becomes a challenge in browsers aside from Firefox, as table cells do not flex in height as they do in width.
3. CSS3 flexbox and CSS3 grids
Though promising, flexbox and grids face browser compatibility issues. Flexbox lacks support in IE9 and earlier, while grids currently only have full support in IE10. Testing is required to determine if either can successfully achieve the desired layout.
Summary
- Floats do not provide a cross-browser solution.
- HTML tables and CSS tables do not offer reliable cross-browser solutions.
- Flexbox may not offer a solution for IE9 or earlier (and potentially other browsers).
- Grids may be a potential solution for IE10 (and potentially other browsers).
Conclusion
At present, there seems to be no ideal CSS solution that is widely compatible across relevant browsers, except possibly flexbox (if support for IE9 and earlier is not a requirement).
jQuery
Below are two jQuery-modified demos that ensure both columns have the same height. The CSS and jQuery code are identical for both demos, with differences only in the amount of content in each column. These demos have been tested successfully in all major browsers. A similar approach could be implemented using plain JavaScript.
To simplify matters, the internal padding for the left and right div has been moved to a child element (.content
).