Centering a div of unknown width


 / Published in: CSS
 

  1. .message-container {
  2. margin: 0 auto 8px;
  3. display: table;
  4. }
  5.  
  6. .message-container div {
  7. display: table-cell;
  8. }
  9.  
  10.  
  11. <!--[if IE]>
  12. .message-container {
  13. display: block;
  14. text-align: center;
  15. }
  16. .message-container div {
  17. display: inline;
  18. zoom: 1;
  19. }
  20. <![endif]-->

Report this snippet  

Comments

RSS Icon Subscribe to comments
Posted By: vertoo on May 10, 2008

Posted By: Nix on February 13, 2010

The first message-container must begin with "#", not "." so it can work :)

You need to login to post a comment.