Jump to content
Killersites Forums

How do I center my page?


TheAppleNewsreel
 Share

Recommended Posts

Wrap a div around the whole thing. The way you do that is apply the open div just after the open body tag and the a closed div just before the closing body tag.

 

<body>

<div style="margin: 0 auto; width: 900px;"> Note: set your width to whatever size your framework is.

 

</div>

</body>

Link to comment
Share on other sites

This is how I center my page:

 

#wrapper {

width: 960px;

margin-top: 20px;

margin-right: auto;

margin-left: auto;

}

I put all of my content links,main content ect. inside of the wripper div and use this css to center it in the browser window. The centering part is the margin-right: auto; margin-left: auto; I hope this helps.

Link to comment
Share on other sites

If you have any divs or other elements with position: absolute you will almost certainly need to add position: relative to the wrap div as position: absolute elements will be unaffected unless you do add it:-

<body>
<div style="position: relative; margin: 0 auto; width: 900px;"> 
Note: set your width to whatever size your framework is.
</div>
</body> 

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
 Share

×
×
  • Create New...