Advertisement
If you have a new account but are having problems posting or verifying your account, please email us on hello@boards.ie for help. Thanks :)
Hello all! Please ensure that you are posting a new thread or question in the appropriate forum. The Feedback forum is overwhelmed with questions that are having to be moved elsewhere. If you need help to verify your account contact hello@boards.ie
Hi there,
There is an issue with role permissions that is being worked on at the moment.
If you are having trouble with access or permissions on regional forums please post here to get access: https://www.boards.ie/discussion/2058365403/you-do-not-have-permission-for-that#latest

Mixture of td widths in a table

  • 04-10-2006 11:38am
    #1
    Registered Users, Registered Users 2 Posts: 4,475 ✭✭✭


    I have a table with 3 columns. I want column 1 to be 100 pixels wide, and the other two to scale to the width of the page. I don't know how wide the table will be, it's set to 100%. If I use the following:
    <table...>
        <tr>
            <td width="100"></td>
            <td width="50%"></td>
            <td width="50%"></td>
        </tr>
    </table>
    
    then it appears that the first column is set correctly, but the second column takes over 50% of the screen width rather than 50% of what's left.

    I have more than 3 columns in my actual table, I have 9, and some I want to be fixed widths while the others scale. Is there any way of doing this, short of table within table?


Comments

  • Closed Accounts Posts: 8,866 ✭✭✭Adam


    I'm pretty sure this is going to have to be css...

    EDIT: you can do them all with pixels, or all with percentages but you can't interchange as far as I can see...so doing it with percentages(because I wouldnt recommend using pixels) simply means you have to set the table width to 100% and work out by eye the widths you want the rest to be.

    The reason I'm saying I would favour percentages is because they will scale on different peoples monitors and resolutions.


  • Registered Users, Registered Users 2 Posts: 4,475 ✭✭✭corblimey


    The reason I'd like to do this is because I have a fixed-width dropdown in some of the columns. The client has requested that the other columns scale correctly, and keep asking about all the 'space' in the column with the dropdown when I have everything set to percentages and increase the resolution.

    Screw 'em :)


  • Closed Accounts Posts: 8,866 ✭✭✭Adam


    Pfft, clients :rolleyes: :D


  • Closed Accounts Posts: 4,943 ✭✭✭Mutant_Fruit


    <table width"300px"...>
        <tr width = 50%>
            <td width="100"></td>
            <td width="50%"></td>
            <td width="50%"></td>
        </tr>
    </table>
    
    Try specifying the width of the TR explicitly (either as a % total of the table or as a pixel width, i chose 50% of the width of the table, which i defined to be 300px).


  • Registered Users, Registered Users 2 Posts: 15,443 ✭✭✭✭bonkey


    Can't you use a single td with no with specified so it takes all remaining space? And then inside this td define two columns each taking 50% of available space?


  • Advertisement
  • Closed Accounts Posts: 4,943 ✭✭✭Mutant_Fruit


    bonkey wrote:
    Can't you use a single td with no with specified so it takes all remaining space? And then inside this td define two columns each taking 50% of available space?
    It'd mean having to put a table inside that single large TD and defining a row and two new TD's in that table. According to some that's a big no-no


  • Closed Accounts Posts: 8,866 ✭✭✭Adam


    It'd mean having to put a table inside that single large TD and defining a row and two new TD's in that table. According to some that's a big no-no
    True, but I was wondering did you test your suggested method? It didn't work for me.


  • Registered Users, Registered Users 2 Posts: 8,488 ✭✭✭Goodshape


    bonkey wrote:
    Can't you use a single td with no with specified so it takes all remaining space? And then inside this td define two columns each taking 50% of available space?
    That's what I was thinking (don't see another way of doing it with tables), but then I thought that the two inside columns would take up 50% of the screen width regardless.

    Maybe not tough, worth trying (don't have an editor open atm, so I'm not going to bother :P).

    ..although, obviously, you should be using a few DIV's and some CSS for this sort of thing these days.


  • Moderators, Science, Health & Environment Moderators Posts: 9,035 Mod ✭✭✭✭mewso


    It'd mean having to put a table inside that single large TD and defining a row and two new TD's in that table. According to some that's a big no-no

    Looks like this table is for layout anyway so no-nos are go-go.


  • Registered Users, Registered Users 2 Posts: 303 ✭✭brian_rbk


    <table width = 100% BORDER=1>
    <tr>
    <td width ="100">
    <td width = "*">
    <td width = "*">
    </tr>
    </table>

    this help ?


  • Advertisement
  • Moderators, Politics Moderators Posts: 41,240 Mod ✭✭✭✭Seth Brundle


    Could a number of divs not be used?
    div1 = 100% & contains
    div2 = 100px
    div3 = * & contains
    div4 = 50%
    div5 = 50%


  • Registered Users, Registered Users 2 Posts: 4,475 ✭✭✭corblimey


    Yeah, I tried the table within a table method (or kbannon's div within a div alternate) and it didn't look too good, so I'm trying to come up with a layout that works for me and the client. Thanks all.


Advertisement