FORUMS: list search recent posts

What is the best way to center the entire page with div and css?

COW Forums : Web Design

<< PREVIOUS   •   FAQ   •   VIEW ALL   •   PRINT   •   NEXT >>
Hau Li
What is the best way to center the entire page with div and css?
on Jan 13, 2009 at 9:32:07 pm

Hi,

I was having headaches with tables, so I drop a jpeg that I made and sliced in photoshop into dreamweaver and traced it which creates div tags. I uploaded it and everything shift to the left again.
I wasn't able to make tables since it seems to give me that 1 pixel gap between the picture and the table...

What do you think of my WIP site?
http://www.tvholicjamie.com


Return to posts index

Abraham Chaffin
Re: What is the best way to center the entire page with div and css?
on Jan 13, 2009 at 10:01:06 pm

You can surround your content with a div that is set with the specific width of your page content and then assign a margin of left auto and right auto:

#main_wrapper {
width: 900px;
margin: 0 auto 0 auto; /* Sets the margin properties for an element using shorthand notation (top, right, bottom, left) auto right and left will centre it in the browser */
}


Abraham


Return to posts index

Fernando Mol
Re: What is the best way to center the entire page with div and css?
on Jan 22, 2009 at 6:23:33 am

As Abraham says, you should add a new div to the code covering the entire body of your page.

<body>
<div id="main_wrapper">

<!-- your content here -->

</div>
</body>


But you'll also need to add a relative position attribute to the main_wrapper div because all of your "Layer" divs are absolute positioned.



Return to posts index

<< PREVIOUS   •   VIEW ALL   •   PRINT   •   NEXT >>
© 2017 CreativeCOW.net All Rights Reserved
[TOP]