Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3
  1. #1
    New to the CF scene
    Join Date
    Jul 2005
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Input width within table

    Hi,

    I need to place input fields within a table, and want their width to expand to the width of the column... The following seems to work within IE, but in Firefox, the input fields actually expand the width of the table to be 100% of the screen... I thought when setting the width of the input to 100%, it would have been with respect to the parent TD element it was placed within... Why is it actually resizing the TD too?

    Code:
    <html>
    <head>
    </head>
    <body>
    
    <table  border="1">
    <tr style="font-weight: bold;">
    <td width=100>Name</td>
    <td>Id</td>
    <td>Item</td>
    <td>Time</td>
    <td>Date</td>
    <td>Tier</td>
    <td>Status</td>
    <td>Comments</td>
    </tr>
    
    <tr>
    <td><input style="width:100%"></td>
    <td><input style="width:100%"></td>
    <td><input style="width:100%"></td>
    <td><input style="width:100%"></td>
    <td><input style="width:100%"></td>
    <td><input style="width:100%"></td>
    <td><input style="width:100%"></td>
    <td><input style="width:100%"></td></tr>
    
    </table>
    <br>
    </body></html>
    Cheers

    Siam

  • #2
    Senior Coder
    Join Date
    Apr 2007
    Location
    Quakertown PA USA
    Posts
    1,028
    Thanks
    1
    Thanked 125 Times in 123 Posts
    You don't have a width set for the <table>

  • #3
    Senior Coder koyama's Avatar
    Join Date
    Dec 2006
    Location
    Copenhagen, Denmark
    Posts
    1,246
    Thanks
    1
    Thanked 5 Times in 5 Posts
    Remember that CSS 2.1 does not define the meaning of a percentage width for an element whenever the containing block's width depends on the width of that element. This is the case for elements within a table cell in the automatic table layout.

    Maybe you should instead find some kind of compromise such as explicitly setting the width of each input element to a value that makes it just a bit wider than the column heading.


  •  

    Posting Permissions

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