View Single Post
  #4 (permalink)  
Old Dec 6th, 2007, 10:48
hschmitz hschmitz is offline
Up'n'Coming Member
Join Date: Jun 2007
Location: Birmingham, UK
Posts: 54
Thanks: 0
Thanked 0 Times in 0 Posts
Re: Centering Vertically

Hi Dan,

the problem is, that you cannot change the size of the body element. The body element always represents the complete visible page. Instead you have to place a separate div inside the body. To get that div centered, try something like

Code: Select all
.centered {
  position: absolute;
  top: 50%;
  left: 50%;
  margin-top: -250px;
  margin-left: -390px;
  width: 780px;
  height: 500px;
  background-color:#313e5b;
}
And the HTML should then look like

Code: Select all
<body>
<div class="centered">
    Content here
</div>
</body>
Hope this helps
Reply With Quote