Posted By

jarnaldich on 01/10/09


Tagged

css


Versions (?)

Who likes this?

2 people have marked this snippet as a favorite

basicmagic
ozayo


Horizontally Centering a div with CSS


 / Published in: CSS
 

Centering a div with css is easy, but there are some compatibility quirks...

  1. #wrapper {
  2. text-align: center; /* IE misinterprets this so it centers the child div */
  3. min-width: 600px;/* To keep the look on resize for mozilla */
  4. }
  5.  
  6. #centered {
  7. margin:0 auto; /* sets left and right margin to auto. Works for mozilla, not for IE */
  8. width:600px; /* or whatever size for the div */
  9. text-align: left; /* to override wrapper IE misinterpretation */
  10. }

Report this snippet  

Comments

RSS Icon Subscribe to comments
Posted By: dmatranga on February 4, 2009

thanks for posting, i'll definitely be saving this one.

-dan

Posted By: dmatranga on February 4, 2009

thanks for posting, i'll definitely be saving this one.

-dan

You need to login to post a comment.