left-right-center aligned

Discussion in 'HTML' started by mre, Mar 10, 2005.

  1. mre

    mre Guest

    Hi

    Is it possible to have each column cell in a table to be left-aligned
    with each other, but also right-aligned with the cell based on the
    longest content.

    So a table like...

    <table>
    <tr><td>aaa</td><td>bbb</td></tr>
    <tr><td>aaaaaa</td><td>bbb</td></tr>
    <tr><td>aaaaa</td><td>bbb</td></tr>
    </table>

    ....could be output like...

    ______Left align
    |
    [[ aaa ][bbb ]]
    [[ aaaaaa][bbb ]]
    [[ aaaaa ][bbb ]]
    |____|
    |___Right align as a group
    to the center of the table

    ....at the moment, the closest I have is right-aligning the TD, and in
    that, having a left-aligned SPAN where I set the em width manually -
    but as the page is generated dynamically, I can only really guess what
    that'll be.


    Thank you for any help,
    Regards,
    MRe
     
    mre, Mar 10, 2005
    #1
    1. Advertising

  2. mre

    Els Guest

    mre wrote:

    > Hi
    >
    > Is it possible to have each column cell in a table to be
    > left-aligned
    > with each other, but also right-aligned with the cell based
    > on the longest content.
    >
    > So a table like...
    >
    > <table>
    > <tr><td>aaa</td><td>bbb</td></tr>
    > <tr><td>aaaaaa</td><td>bbb</td></tr>
    > <tr><td>aaaaa</td><td>bbb</td></tr>
    > </table>
    >
    > ...could be output like...
    >
    > ______Left align
    > |
    > [[ aaa ][bbb ]]
    > [[ aaaaaa][bbb ]]
    > [[ aaaaa ][bbb ]]
    > |____|
    > |___Right align as a group
    > to the center of the table
    >
    > ...at the moment, the closest I have is right-aligning the
    > TD, and in that, having a left-aligned SPAN where I set the
    > em width manually - but as the page is generated
    > dynamically, I can only really guess what that'll be.


    Just make sure the cell width is small enough to have the
    largest content touch the right side of the column, and then
    left-align with a left padding?

    --
    Els
    http://locusmeus.com/
    Sonhos vem. Sonhos vão. O resto é imperfeito.
    - Renato Russo -
     
    Els, Mar 10, 2005
    #2
    1. Advertising

  3. mre

    MRe Guest

    > mre wrote:
    > > Is it possible to have each column cell in a table to be
    > > left-aligned
    > > with each other, but also right-aligned with the cell based
    > > on the longest content.


    > Els wrote:
    > > Just make sure the cell width is small enough to have the
    > > largest content touch the right side of the column, and then
    > > left-align with a left padding?


    Hi Els, thank you for the response.

    <oops>
    Sorry, I should also have mentioned in my previous post that my
    table width was 100% and columns were 50% each
    </oops>

    I tried playing around with different ideas based on your reply, and
    the best I came up with this (below) - are there better ways? I don't
    know how to make something small enough to fit the largest content -
    how's it done? - or was that response based on the fact that I'm an
    idiot and forgot to mention the width of my table/cells?

    <table style="width: 100%;">
    <tr>
    <td></td>
    <td width="1px"><div style="white-space: nowrap;">abc def</div></td>
    <td width="50%">fdsafd</td>
    </tr>
    <tr>
    <td></td>
    <td width="1px"><div style="white-space: nowrap;">a b c</div></td>
    <td width="50%">fdaf</td></tr>
    </table>

    Thank you for your help :)
    Regards,
    MRe
     
    MRe, Mar 10, 2005
    #3
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. DU
    Replies:
    8
    Views:
    625
    Toby A Inkster
    Oct 8, 2003
  2. ComputerSnack
    Replies:
    7
    Views:
    1,876
    Jonathan N. Little
    Apr 13, 2006
  3. =?Utf-8?B?QmlzaG95?=
    Replies:
    0
    Views:
    992
    =?Utf-8?B?QmlzaG95?=
    Dec 28, 2006
  4. AAaron123
    Replies:
    1
    Views:
    340
    AAaron123
    Jul 21, 2008
  5. topguy
    Replies:
    6
    Views:
    511
    topguy
    Nov 15, 2008
Loading...

Share This Page