Center entire page with CSS

Hitler

Member
Apr 21, 2013
33
8
Hello, I'm having troubles with centering the entire page, currently it looks like this..
cd7fbf4740f0407eaa18342.png


I'm using a wrapper which I have everything inside of which is this (btw, I still want the two boxes in-line with each-other, just want it centered horizontally).
Code:
#wrapper {
    margin: 0 auto;
    width: 1008px;
    text-align:left;
    }

I suck at CSS, so I'm doing this to get more comfortable with it.
Thanks,
Hitler.
 

Queef

Some people...
Jul 27, 2012
645
289
Try the following code:

Code:
#wrapper {
margin: 0 auto;
width: 1008px;
text-align:left;
position:absolute;
top:50%
margin-top:(HALF OF THE HEIGHT AS A NEGATIVE NUMBER);
left:50%
margin-left:-504px;
}
 

Hitler

Member
Apr 21, 2013
33
8
Not sure if you went the whole document as in css file or index so here's both.
The index.php file,
HTML:
<!DOCTYPE html>
<html>
<head>
<title> Ermahgerd </title>
<link rel="stylesheet" type="text/css" href="/styles/global.css">
</head>
<body>
<div id="wrapper">
<div id="header">
<div id="navbar">
<form>
<input type="text" placeholder="Hurdedur" />
</form>
</div>
</div>
</div>
</body>
</html>

CSS file (I was testing different things to see what would work so it looks really weird with the placement of codes, in my opinion anyway).
HTML:
body {
    background-color: #F2F2F2;
    font-size: 13px;
    font-family: 'Helvetica';
    color: white;
    text-align: center;
    margin: 0 auto;
    width: 1008px;
    text-align:left;
    position:absolute;
    top:50%
    margin-top:-334px;
    left:50%
    margin-left:-504px;
    }
 
#header {
    margin-top:97px;
   
    }
   
#navbar {
    border-radius:3px;
    background-color: #373737;
    width:547px;
    height:35px;
    }
   
#navbar form input[type="text"]{
    margin-left:564px;
    width:417px;
    height:35px;
    border-radius:3px;
    border:1px solid #FFF;
    }
   
   
#updatemotto  form input[type="text"]{
    margin-left:17px;
    width:303px;
    height:35px;
    border-radius:3px;
    border:1px solid #000;
    }
   
#updatemotto form label input[type="submit"] {
    margin-left
 

Users who are viewing this thread

Top