Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Centering

Status
Not open for further replies.

ice78991

Programmer
Joined
Nov 20, 2006
Messages
216
Using tables, it is easy to
center the page vertically and horizontally (<table height="100%"> etc) on the screen

How is this best done using css
 
For the width, you could use a "container" div and use "margin: 0 auto".


____________________________________________________________

Need help finding an answer?

Try the Search Facility or read FAQ222-2244 on how to get better results.

 
Thanks. I'm trying to workk out how to center in terms of the height ? Is there a way which is compatible with all browsers?
 
or is this one area where it is better to stick to tables?
 
I have been getting quite close with the following

<div style=" margin-left: 50%; margin-top: 25%">
SomeText
</div>

Not sure why margin-top: 50% goes off screen though.
 
awesome I was about to start a topic on this. Thanks :}
 
AFAIK, this is one of the best methods of both horizontal and vertical centering: The example does not have a complete doctype but I have tested it to work with a complete one as well.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top