Possible Duplicate:
Two divs, one fixed width, the other, the rest
I want 2 div
s side by side, where the right has a random width (this contains another 2 div
s - a header with a random text and a body with a random image, all generated by JS) while the left should use the remaining width (this also contains another 2 div
s - a header and a body, both containing static text only).
I currently have a solution with 3 table
s that was quite simple do come up with, but as I'm recoding all my tables without strict tabular contents to CSS (yes I'm quite a few years late with this) I would prefer to have this in CSS too, if it's at all possible? After searching for a solution for quite some time it seems it may not be...
Worth noting is that the image height is always the same, also the width of every image is specified in the JS.
My current solution (with the JS and more stripped out to be as simple and clear as possible, the image is just an example and may have a width of up to 250px): My fiddle
HTML:
<table class="container" cellpadding="0">
<tr>
<td>
<table class="left">
<thead>
<tr>
<th>Text Header</th>
</tr>
</thead>
<tbody>
<tr>
<td>This just contains text.
</td>
</tr>
</tbody>
</table>
</td>
<td>
<table class="right">
<thead><tr>
<th>Image Header</th>
</tr></thead>
<tbody>
<tr>
<td>
<img src="http://www.derdiz.com/wp-content/uploads/2011/06/vertigo.jpg" width="200" height="200" border="0" style="display:block;">
</td>
</tr>
</tbody>
</table>
</td>
</tr>
</table>
CSS:
table {
border-collapse: collapse;
}
table.container {
width: 500px;
background-color: #DDD;
border: 1px solid #0F0;
}
.container td {
vertical-align: top;
}
table.left {
border: 0px;
}
table.right {
border-left: 1px solid #F00;
}
.left th, .left td, .right th, .right td {
padding: 3px;
}
.left thead th, .right thead th {
background-color: #00F;
color: #FFF;
font-weight: bold;
text-align: left;
}
.right tbody td {
background-color: #888;
}
Please tell if you also want the JS and my unfinished CSS only solution.