View Full Version : Simple Alignment Question
12-03-2006, 04:48 AM
I am quite capable in CSS but one thing that has never worked for me in the past is universal centering for all resolutions. You can use absolute coordinates but obviously it will only look as good as the rez you are working on it. I'm pretty certain I could write a VB function to adapt the alignment per resolution but that makes things very sloppy. For tidiness sake, how does one keep things in CSS aligned to the middle of the page?
I have tried using
but no dice.... I will be googling in the mean....
12-03-2006, 07:06 AM
margin: 0px auto;
That centers it left and right... horizontally centering things is a little more difficult.
12-03-2006, 03:09 PM
The text-align: center declaration is not for centering block‐level content, but for centering text. Internet Explorer will allow you to get away with doing otherwise if youíve set up your document such that it displays in backward compatibility mode, however.
The margin: 0 auto declaration should work fine for keeping your layout centered in any resolution. Just remember that Internet Explorer doesnít allow you to use it for centering purposes while in backward compatibility mode and that you canít center a normal block‐level element (e.g., div) that doesnít have a defined width.
Anyway, if you want a dynamic layout, you can use a combination of absolute and relative units along with the min-width and min-height properties. Percentages and ems in particular are good for dynamic appearances.
Powered by vBulletin® Version 4.2.2 Copyright © 2016 vBulletin Solutions, Inc. All rights reserved.