Dead simple centered fixed width layout
January 15, 2010 - 7:02pm
Just because I tend to forget these things, I am putting it down on the site so it is immortalized !!! This small snippet of CSS is creating a fixed width centered layout, without using an outer containing div. Because we all love nice meaningful markup and we all hate div-itis.
body {
width: 960px; /* or whatever you want */
margin: 0 auto;
text-align: left;
}
The margin of "auto" for left and right will keep us nice and centered and our body width makes sure we get our pixel-perfect fixed layout :)
Filed Under
Related Content
I pwn
Oh hai, my name is Becky and this is my personal website about tech and sometimes my life. I work as a user experience designer for UniversityNow, and I live in San Francisco but I bleed New York.
Comments
Very Useful!
I borrowed this code a few days ago to tweak a layout I have been tinkering with. Very helpful stuff to have! Thanks!
Pages