Making page appear in the center of the screen
Posted: 05 June 2007 09:34 PM   [ Ignore ]
Newbie
Rank
Total Posts:  3
Joined  2007-06-05

I have designed my website using HTML and CSS successfully. I created divs and classes for the entire site and it looks great. But my problem now is I want the page to appear in the center of the page and I have not been able to do it right.

Could someone tell me how to align my page to the center of the screen please.

Thanks in advance!

Menre

Profile
 
 
Posted: 06 June 2007 07:58 PM   [ Ignore ]   [ # 1 ]
Newbie
Rank
Total Posts:  1
Joined  2007-06-06
body {text-align:center;

Its considered a hack and may not be the correct way to do it, but it always gets the job done for me.

Good luck hope that helps.

Profile
 
 
Posted: 15 June 2007 09:13 AM   [ Ignore ]   [ # 2 ]
Newbie
Avatar
Rank
Total Posts:  3
Joined  2007-06-15

Hi,

Use:

margin0 auto

This is a cross browser trick.

the

text-align:center

does not work in firefox.

hope this helps you.

add the margin tag to the content you wanna center not the body tag for example:

.examplediv { width200pxheight500pxbackgroundgreenborder1px dashed blackmargin0 auto

jono

Profile
 
 
Posted: 21 June 2007 10:24 PM   [ Ignore ]   [ # 3 ]
Newbie
Rank
Total Posts:  10
Joined  2007-06-21

Usually you have to use both of the above methods. I think that IE doesn’t like the correct way, so the text-align is for it.

Just make sure all other important divs have the text-align set back to left, or some browsers will center everything.

Profile
 
 
Posted: 23 June 2007 04:24 AM   [ Ignore ]   [ # 4 ]
Newbie
Rank
Total Posts:  21
Joined  2007-05-05

yep - the 1st bit you need for IE.. pain in the ass!

Profile
 
 
Posted: 23 June 2007 05:22 AM   [ Ignore ]   [ # 5 ]
Newbie
Rank
Total Posts:  3
Joined  2007-06-23
Jono - 15 June 2007 09:13 AM

Hi,

Use:

margin0 auto

This is a cross browser trick.

the

text-align:center

does not work in firefox.

hope this helps you.

add the margin tag to the content you wanna center not the body tag for example:

.examplediv { width200pxheight500pxbackgroundgreenborder1px dashed blackmargin0 auto

jono

to support

Profile
 
 
Posted: 28 June 2007 12:03 PM   [ Ignore ]   [ # 6 ]
Newbie
Rank
Total Posts:  15
Joined  2007-06-28

Actually i was looking for that code thanks for the code :D

Profile
 
 
Posted: 25 July 2007 11:15 PM   [ Ignore ]   [ # 7 ]
Newbie
Rank
Total Posts:  3
Joined  2007-06-05

Thanks to everyone that responded to my question. I have tried out all your suggestions and they actually worked as you said.
Once again, thank you.

Menre

Profile