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 13 of 13
  1. #1
    New Coder
    Join Date
    Aug 2002
    Posts
    14
    Thanks
    0
    Thanked 0 Times in 0 Posts

    CSS, table centering

    Can someone help me out?

    http://users.skynet.be/shivand/EMC/

    I need to center that table, so the larger the screenresolution is, the larger both black sides become ... How can I do this with CSS, cause i don t get i fixed

    Thx

    ShivanD

  • #2
    New Coder
    Join Date
    Aug 2002
    Posts
    14
    Thanks
    0
    Thanked 0 Times in 0 Posts
    this table:

    <div style=" ??????? ">
    <table border="0" cellpadding="0" cellspacing="0" width="768" height="458">
    <tr>
    <td background="images/LeftUpper.jpg" height="54" width="178">&nbsp;</td>
    <td background="images/Upper.jpg" width="401" height="54">&nbsp;</td>
    <td background="images/RightUpper.jpg" width="189" height="54">&nbsp;</td>
    </tr>
    <tr>
    <td background="images/Left.jpg" width="178" height="339">&nbsp;</td>
    <td bgcolor="#000000"> <div class="Content">
    <p>terssssskjlkjsqlkjlksqdjlqkjdsq</p>
    <p>lksqdlmkmlkmsdql</p>
    <p>mlksqdmlkmlkqsd</p>
    <p>qsdlkmlksdq</p>
    <p>sqkjlksdqj</p>
    <p>sqdlkjqsd</p>
    <p>&nbsp; </p>
    </div>
    </td>
    <td background="images/emcTemplate_r2_c4.jpg" width="183" height="339">&nbsp;</td>
    </tr>
    <tr>
    <td background="images/LeftUnder.jpg" width="178" height="65">&nbsp;</td>
    <td background="images/Under.jpg" height="65" width="401">&nbsp;</td>
    <td background="images/RightUnder.jpg" height="65" width="189">&nbsp;</td>
    </tr>
    </table>
    </div>

  • #3
    Regular Coder
    Join Date
    Oct 2002
    Posts
    380
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Code:
    <div style="text-align: center;">
    <!-- table here -->
    </div>

  • #4
    Senior Coder
    Join Date
    Jul 2002
    Posts
    1,628
    Thanks
    0
    Thanked 0 Times in 0 Posts
    does that work in every browser, i am at work so i cant check, but i seem to remember having problems centering my table with the div element like that.

    Moderator: General web building

    Get out from under them, resist and multiply.
    Get out from under precipice and see the sky.

  • #5
    New Coder
    Join Date
    Aug 2002
    Posts
    14
    Thanks
    0
    Thanked 0 Times in 0 Posts
    aight i fixed it, thx dude

  • #6
    Regular Coder
    Join Date
    Oct 2002
    Posts
    380
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Not sure about all broswers. It does with IE5+ and NS6/Moz. Oh, I forgot to mention, you might need to re-do the text align in the child elements. They should inherit the text-align from the parent (although tables don't do this very often).

  • #7
    Senior Coder
    Join Date
    Jul 2002
    Posts
    1,628
    Thanks
    0
    Thanked 0 Times in 0 Posts
    wont work crossbrowser in xhtml11 markup (strict) in ie6/win for me

    Moderator: General web building

    Get out from under them, resist and multiply.
    Get out from under precipice and see the sky.

  • #8
    New Coder
    Join Date
    Aug 2002
    Posts
    14
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Originally posted by cg9com
    wont work crossbrowser in xhtml11 markup (strict) in ie6/win for me
    what?

  • #9
    jkd
    jkd is offline
    Senior Coder jkd's Avatar
    Join Date
    May 2002
    Location
    metro DC
    Posts
    3,163
    Thanks
    1
    Thanked 18 Times in 18 Posts
    table {
    margin: 0 auto;
    }


    A table is a block-level element, and therefore should not be affected by text-align. text-align centering block elements was a BUG in IE's rendering model, and is fixed in strict mode rendering in IE6.

    margin: 0 auto;

    Is the correct way of centering any block level element through CSS.

  • #10
    New Coder
    Join Date
    Aug 2002
    Posts
    14
    Thanks
    0
    Thanked 0 Times in 0 Posts
    why (margin: 0 auto)

    2 values??

  • #11
    Senior Coder
    Join Date
    Jul 2002
    Posts
    1,628
    Thanks
    0
    Thanked 0 Times in 0 Posts
    thanks jkd

    Moderator: General web building

    Get out from under them, resist and multiply.
    Get out from under precipice and see the sky.

  • #12
    jkd
    jkd is offline
    Senior Coder jkd's Avatar
    Join Date
    May 2002
    Location
    metro DC
    Posts
    3,163
    Thanks
    1
    Thanked 18 Times in 18 Posts
    Originally posted by Shivandragon
    why (margin: 0 auto)

    2 values??
    margin: allmargins
    margin: topbottommargin leftrightmargin
    margin: topmargin rightmargin bottommargin leftmargin

    Can't say
    margin: auto;
    because auto isn't correct for vertical margins
    margin: 0 auto;
    gives it 0 vertical margins, and centers it horizontally
    margin: 0 auto 0 auto;
    also works

    You could also say:
    margin-left: auto;
    margin-right: auto;

  • #13
    New Coder
    Join Date
    Aug 2002
    Posts
    14
    Thanks
    0
    Thanked 0 Times in 0 Posts
    thx for your time and explenation...

    Greetz

    ShivanD


  •  

    Posting Permissions

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