Results 1 to 8 of 8

Thread: Vertical Center

  1. #1
    Join Date
    Feb 2006
    Posts
    61
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Vertical Center

    here i am been designing websites for a while and i cant get a stupid table to vertically align, its a 800 by 800 table for a splash page, i need it horizontally and vertically centered. why wont any of my valign or TD align things work? what is wrong??


    PS. can anybody repost the tag to make flash animations not go over stuff? was it like wmode="transparent" or something?
    Last edited by Merciless; 02-05-2007 at 05:35 AM.

  2. #2
    Join Date
    Sep 2005
    Location
    India
    Posts
    1,627
    Thanks
    6
    Thanked 107 Times in 107 Posts

    Default

    1. using HTML tables

    Code:
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    <title>Untitled Document</title>
    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
    <style type="text/css">
    
    </style>
    </head>
    
    <body>
    <table cellspacing="0" cellpadding="0" width="100%" border="1" height="100%">
    <tr><td width="100%" align="center" valign="middle">
    <table cellspacing="0" cellpadding="0" width="800" border="1" height="800">
    <tr><td align="center">Test</td></tr>
    </table>
    </td></tr>
    </table>
    </body>
    </html>
    2. Instead of using a table based solution you can go for a CSS & DIV based solution, which is more efficient compared to the above one.

    Have a look at this article where they explained achieving vertical centering using CSS

  3. #3
    Join Date
    Mar 2005
    Location
    SE PA USA
    Posts
    30,495
    Thanks
    82
    Thanked 3,449 Times in 3,410 Posts
    Blog Entries
    12

    Default

    Vertical centering on a page is not a simple matter. There are ways, see:

    http://www.wpdfd.com/editorial/thebox/deadcentre3.html

    As for your other question, just look back over your old threads, particularly:

    http://www.dynamicdrive.com/forums/s...ad.php?t=16785
    - John
    ________________________

    Show Additional Thanks: International Rescue Committee - Donate or: The Ocean Conservancy - Donate or: PayPal - Donate

  4. #4
    Join Date
    Feb 2006
    Posts
    61
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    k code, thx but i needed to figure out how to center the whole table itself not the content inside the table. and thanks for that link js, though i am having a hard time translating the second instruction, i will look into i further and come back if i have any problems.

    EDIT: i will use the code to figure it out no need to spend any more time posting about it, and thank you for finding my old post js thats just the thing i was looking for.

  5. #5
    Join Date
    Feb 2006
    Posts
    61
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    my problem continues, my image might center. maybe, but my first concern is the fact that my table is IGNORING my fixed height that i set, not only will it not do 100%, it will not even go to the pixel amount that i set. what on earth is going on? here is the link to the web page, i would like to center that completely with like 10px of table space on each side of the picture directly in the middle of the page, nothing i do to the code seems to change anything, help pl0x,

    here is the link to the page, http://www.imikya.com/betatesting/nmsplash.htm

  6. #6
    Join Date
    Mar 2005
    Location
    SE PA USA
    Posts
    30,495
    Thanks
    82
    Thanked 3,449 Times in 3,410 Posts
    Blog Entries
    12

    Default

    Code:
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
    "http://www.w3.org/TR/html4/loose.dtd">
    <html>
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
    <title>Untitled Document</title>
    <style type="text/css">
    
    body,td,th {
    	color: #FFFFFF;
    }
    body {
    	background-image: url(http://www.imikya.com/betatesting/bftest.jpg);
    }
    table {
    position:absolute;
    top:50%;
    left:50%;
    margin-left:-425px;
    margin-top:-288px;
    }
    
    </style></head>
    
    <body>
    <table width="850" height="576" border="0" cellpadding="10" cellspacing="0" bgcolor="#000000">
      <tr>
        <td><div align="center"><img src="http://www.imikya.com/betatesting/splashtest.jpg" width="800" height="556"></div></td>
      </tr>
    </table>
    </body>
    </html>
    But, the image is a little large and will have portions that are unviewable at 800x600 resolution screens and browser windows that are smaller than 850x650 or there abouts.

    It would be a little better if you skipped the table:

    Code:
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
    "http://www.w3.org/TR/html4/loose.dtd">
    <html>
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
    <title>Untitled Document</title>
    <style type="text/css">
    
    body,td,th {
    	color: #FFFFFF;
    }
    body {
    	background-image: url(http://www.imikya.com/betatesting/bftest.jpg);
    }
    img {
    position:absolute;
    top:50%;
    left:50%;
    margin-left:-400px;
    margin-top:-278px;
    }
    
    </style></head>
    
    <body>
    <img src="http://www.imikya.com/betatesting/splashtest.jpg" width="800" height="556">
    </body>
    </html>
    - John
    ________________________

    Show Additional Thanks: International Rescue Committee - Donate or: The Ocean Conservancy - Donate or: PayPal - Donate

  7. #7
    Join Date
    Feb 2006
    Posts
    61
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    YES, BRILLIANT, thank you so much john, as usual, your the best

    PS. its a high graphic gaming clan, i dont have to worry about anyone having under 1024, but i'll do it anyways, thx
    Last edited by Merciless; 02-05-2007 at 11:45 PM.

  8. #8
    Join Date
    Feb 2006
    Posts
    61
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    STUPID QUESTION ::EDIT:: problem solved, sorry, thanks john.

Bookmarks

Posting Permissions

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