Results 1 to 2 of 2

Thread: How do I VERTICALLY center my webpage?

  1. #1
    Join Date
    Aug 2009
    Posts
    1

    How do I VERTICALLY center my webpage?

    I'm a newbie to webdesign. I've done a lot of research on how to vertically center a website, but I'm left very confused. I've copied my html below. Is there anyone who can help me by telling me what and where I need to place in the code below? Thanks!

    <html>
    <head>
    <title>site</title>
    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
    </head>
    <body bgcolor="#000000" leftmargin="0" topmargin="0" marginwidth="0" marginheight="0">
    <!-- Save for Web Slices (site.jpg) -->
    <center>
    <table id="Table_01" width="1000" height="773" border="0" cellpadding="0" cellspacing="0">
    <tr>
    <td colspan="3">
    <img src="images/index_01.jpg" width="1000" height="265" alt=""></td>
    </tr>
    <tr>
    <td rowspan="2">
    <img src="images/index_02.jpg" width="213" height="508" alt=""></td>
    <td><a href="pdf/pdf.pdf"><img src="images/Link-to-Pdf.jpg" width="573" height="208" border="0"></a></td>
    <td rowspan="2">
    <img src="images/index_04.jpg" width="214" height="508" alt=""></td>
    </tr>
    <tr>
    <td>
    <img src="images/index_05.jpg" width="573" height="300" alt=""></td>
    </tr>
    </table>
    <center>
    <!-- End Save for Web Slices -->
    </body>
    </html>

  2. #2
    Join Date
    Sep 2008
    Posts
    899
    You can play around with the #horizon's margin-top value to adjust the site vertically. You'll also have to set the div widths to your own site's requirements. It should center vertically fairly well in all resolutions as well as center horizontally unless I left something out. I copied this from one of my centered (horizontally and vertically in all resolutions) unpublished sites. Works great on my own Apache. I haven't gotten around to moving the inline style into the head. Mybad!
    Code:
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTL 1.0 Transitional//EN"
    	"http://www.w3.org/TR/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    	
    	<head>
    <style type="text/css" media="screen">
    	   #horizon {
    	   background-color: transparent;
    	   position: absolute;
    	   top: 50%;
    	   left: 0px;
    	   margin-top: -290px;
    	   width: 100%;
    	   }
    	   </style>
    
    	</head>
    
    <body bgcolor="#4b4c4e">
    <div id="horizon">
    <div style="width: 891px; padding-top: 10px; padding-bottom: 10px; position: relative; margin: auto; background-color: white;">	   
    <div id="container_main" style="width: 871px; position: relative; text-align: left; border: 0; background-color: white; margin: auto;">
    	   
    ACTUAL SITE CONTENT HERE
    	
    	</body>
    	</html>
    Last edited by djlebarron; 06 Aug 2009 at 07:54 PM.

Similar Threads

  1. CSS Rendering Horizontal Nav Vertically in All Browsers
    By shelzmike in forum Web Design, HTML Reference and CSS
    Replies: 1
    Last Post: 18 Jun 2009, 02:41 PM

Posting Permissions

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