Centred Div (Horizontally+Vertically)
How do I centre a div, and always keep a 18px gap at the top of the page (before content start) when the browser window is resized?
Not easily is the answer. Here is a link to a page that enables you to put static headers and footers on the page. You could do that, setting each at 18px high, and leaving the content blank, but beware, it is buggy.
To centre a div horizontally, just use margin:auto
You could put an 18px top-padding attribute to the body style.
What I most commonly do is create an all content class. This is a division that holds all the content. I'm guessing you are using a fixed width for the div you want centered.
So what I would do is something like
padding: 18px 0px 0px 0px;
Last edited by matt.ritter; 02-22-2008 at 08:01 AM.
Oh yeah. Sorry. I thought you meant a margin at the top AND bottom. d'oh!
Brilliant! How do I now centre the div horizontally and vertically?
Originally Posted by matt.ritter
Users Browsing this Thread
There are currently 1 users browsing this thread. (0 members and 1 guests)