I've been struggling for hours trying to recreate the same functionality as an old HTML table layout using DIVs.
Inside a parent DIV, I have a simple three-column setup:
- Column-1 contains text and should be as narrow as possible without wrapping (meaning it should adjust its width based on the longest word).
- Column-2 has a fixed width.
- Column-3 should expand to fill the remaining space and have a button in the upper right corner.
Using tables, this is a piece of cake:
<table><tr>
<td width=1%>Foo Bar Baz</td>
<td width=150px><img src="foo.jpg"></td>
<td width=100%><div style="float:right">Button</div>Other stuff. </td>
</tr></table>
This method works perfectly on all browsers except Firefox due to the table inside the parent DIV.
However, when trying with DIVs and CSS, I can't seem to get things right. Specifically: - I'm unable to determine the CSS rules needed to set the first column's width so that "Foo Bar" stays on one line while "Baz" wraps. - I can't figure out how to make the third column expand to take up the leftover space after the first two columns.
I've experimented with various combinations of width:auto, float:left, and word-wrap properties recommended here and elsewhere online. Am I overlooking something obvious?