How to center a DIV

Another one of those useful bits of information that I can never remember, so post it here to help myself (and maybe others!).

#Wrapper {
width: 800px;
position: relative;
left: 50%;
margin-left: -400px; /* half the width of the div */
}

personally, I prefer a fixed width content pane and so this is the cleanest solution for me.

Did you know you can hire me?

I take on projects of all sizes. From Consulting to large Development Projects.

If you're starting a new Yii project and would like some help to get setup and running or you need some help with a particular module or you just need someone to develop the whole dang thing, then just ask ...


Leave a Comment

twitterfacebookgooglelinkedin https://me.yahoo.com