I am looking for a two-stage table layout that behaves like a table . and works in IE7
http://jsfiddle.net/YGb2y/
this works, but it is a table, and as we all know, tables are not an ideal layout. I will use it if necessary, but I would like to find a more semantically appropriate way to do this
notice how the left column is stretched to fit the contained content, and the right column takes up the rest of the available space.
<table> <tr><td class="left">12345</td><td class="right">...</td></tr> <tr><td class="left">123456</td><td class="right">...</td></tr> <tr><td class="left">1234567</td><td class="right">...</td></tr> <tr><td class="left">12345678</td><td class="right">...</td></tr> <tr><td class="left">123456789</td><td class="right">...</td></tr> <tr><td class="left">1234567890</td><td class="right">...</td></tr> </table> table { width:100%; } .left { width:1px; background-color:blue; color:white; } .right { background-color:gray; }
I tried changing this to use ul / li / div, but I can either set a fixed width or a percentage left column. There is no width:stretch-to-fit .
http://jsfiddle.net/cj6PR/
HTML
<ul> <li><div class="left">12345</div><div class="right">...</div></li> <li><div class="left">123456</div><div class="right">...</div></li> <li><div class="left">1234567</div><div class="right">...</div></li> <li><div class="left">12345678</div><div class="right">...</div></li> <li><div class="left">123456789</div><div class="right">...</div></li> <li><div class="left">1234567890</div><div class="right">...</div></li> </ul>
CSS
ul { list-style:none; width:100%; } li { clear:both; position:relative; overflow:hidden; } li div { padding:5px; } .left { float:left; width:20%; background-color:blue; color:white; } .right { background-color:gray; }

Suggestions?
source share