www.webdeveloper.com
Results 1 to 3 of 3

Thread: A way to make the last cell expand?

Hybrid View

  1. #1
    Join Date
    Aug 2003
    Location
    Sydney
    Posts
    24

    Exclamation A way to make the last cell expand?

    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
    Last edited by careyf; 09-18-2003 at 02:28 AM.

  2. #2
    Join Date
    Nov 2002
    Location
    Baltimore, Maryland
    Posts
    12,270
    <!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>
    “The power of the Web is in its universality. Access by everyone regardless of disability is an essential aspect.”
    —Tim Berners-Lee, W3C Director and inventor of the World Wide Web

  3. #3
    Join Date
    Aug 2003
    Location
    Sydney
    Posts
    24
    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.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center



Recent Articles