 |
 |
CSS centering elements question
|
 |
|
 |
|
Professional Poster
Join Date: Jan 2001
Location: Salt Lake City, UT USA
Status:
Offline
|
|
I'm building a webpage for a client. They want the page essentially to be centered all the time, just a slice of the browser window will be the page. Like this: http://www.aspentitle.com/
No matter the width of the window, the table which contains the 'page' remains center. Those guys did it with a <table align="center" /> tag, which works just fine. I could use it, but I'd prefer to use valid html with CSS. According to W3, the align attribute is old school.
Is there an equivalent CSS solution?
Thanks
|
|
2008 iMac 3.06 Ghz, 2GB Memory, GeForce 8800, 500GB HD, SuperDrive
8gb iPhone on Tmobile
|
| |
|
|
|
 |
|
 |
|
Grizzled Veteran
Join Date: Oct 2002
Status:
Offline
|
|
Code:
table {text-align: center;}
|
|
BayBook (13" MacBook Pro, 2.4GHz Core 2 Duo, 4GB RAM, 1TB HD) // BayPhone (iPhone 4, 32GB, black)
|
| |
|
|
|
 |
|
 |
|
Dedicated MacNNer
Join Date: Nov 2001
Location: Are Eye
Status:
Offline
|
|
margin: auto;
use with xhtml doctype
|
|
|
| |
|
|
|
 |
|
 |
|
Professional Poster
Join Date: Jan 2001
Location: Salt Lake City, UT USA
Status:
Offline
|
|
Thanks, precisely what I needed.
|
|
2008 iMac 3.06 Ghz, 2GB Memory, GeForce 8800, 500GB HD, SuperDrive
8gb iPhone on Tmobile
|
| |
|
|
|
 |
|
 |
|
Mac Elite
Join Date: Dec 2004
Status:
Offline
|
|
Don't forget to test in IE  If IE messes it up you also have to add
body {
text-align:center;
}
in addition to margin:auto to your css box elements
|
|
Anyone who denies climate changes naturally is a Climate Change Skeptic.
|
| |
|
|
|
 |
|
 |
|
Professional Poster
Join Date: Jan 2001
Location: Salt Lake City, UT USA
Status:
Offline
|
|
I don't want the text in the table to be centered though.
|
|
2008 iMac 3.06 Ghz, 2GB Memory, GeForce 8800, 500GB HD, SuperDrive
8gb iPhone on Tmobile
|
| |
|
|
|
 |
|
 |
|
Dedicated MacNNer
Join Date: Nov 2001
Location: Are Eye
Status:
Offline
|
|
table? huh? If you're going to use tables for layout, I take my post back.
|
|
|
| |
|
|
|
 |
|
 |
|
Mac Elite
Join Date: Dec 2004
Status:
Offline
|
|
Originally Posted by SirCastor
I don't want the text in the table to be centered though.
Using
body {
text-align:center;
}
won't center your text throughout your layout. Your layout ids will override it with their own margin:auto and text alignment properties. The above is just an IE hack not relevant to other browsers.
|
|
Anyone who denies climate changes naturally is a Climate Change Skeptic.
|
| |
|
|
|
 |
|
 |
|
Professional Poster
Join Date: Jan 2001
Location: Salt Lake City, UT USA
Status:
Offline
|
|
I'm not using tables, it was a temporary example to associate with the situation. I swear I am not using tables for layout.
And, for the sake of reiteration... I hate IE
(I know, we all do, and it was hardly necessary for me to state the obvious...)
|
|
2008 iMac 3.06 Ghz, 2GB Memory, GeForce 8800, 500GB HD, SuperDrive
8gb iPhone on Tmobile
|
| |
|
|
|
 |
|
 |
|
Baninated
Join Date: Mar 2005
Location: An asteroid remanent of Tatooine.
Status:
Offline
|
|
Agree with the mushroom jumper. Some hacks are necassary to make your 'CSS LAYOUT' work in IE  Always cross browser check.
|
|
|
| |
|
|
|
 |
 |
|
 |
|
|
|
|
|

|
|
 |
Forum Rules
|
 |
 |
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
|
HTML code is Off
|
|
|
|
|
|
 |
 |
 |
 |
|
 |
|