Click to See Complete Forum and Search --> : A way to make the last cell expand?


careyf
09-18-2003, 02:22 AM
I was wondering if there was a nice way to create cells such that the first few are together and evenly spaced, but the last one stretches out to fill out the rest of the table width of 100%?

ie

[ cell 1 ][ cell2 ][ cell3 ][cell 4-------------------------------]

At the moment Cells 1,2 and 3 spread out and take up most of the space and cell 4 is tiny. I do not want to set the width of Cells 1-3 as the text length will change depending on the language chosen. So somehow I need to tell cell 4 to expand.

Any solution in HTML tables or CSS is welcome! BUT, there's one tricky thing - I cannot use images (e.g. spacer.gif).

Thanks
Carey

Charles
09-18-2003, 04:46 AM
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
"http://www.w3.org/TR/html4/strict.dtd">
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<meta name="Content-Style-Type" content="text/css">
<title>Example</title>

<style type="text/css">
<!--
table {width:100%}
th, td {border:solid 1px #a00}
-->
</style>

<table>
<tr>
<th style="width:10%">&nbsp;</th>
<th style="width:10%">Heading</th>
<th style="width:10%">Heading</th>
<th style="width:70%">Heading</th>
</tr>
<tr>
<th>Heading</th>
<td>Data</td>
<td>Data</td>
<td>Data</td>
</tr>
<tr>
<th>Heading</th>
<td>Data</td>
<td>Data</td>
<td>Data</td>
</tr>
<tr>
<th>Heading</th>
<td>Data</td>
<td>Data</td>
<td>Data</td>
</tr>
</table>

careyf
09-23-2003, 07:21 PM
Thanks but it's not quite what I was after. I can't set any of cell 1-3 widths, because in fact I don't actually know if there will be 3 or 4 or 7 fields, given that the <td></td> is dynamically generated. I've tried <td width="100%"> in the last cell, but I think it's a bit of a hack.