Horizontally centering elements without width


/ Published in: CSS
Save to your folder(s)

Add two containers to the element to be centered.

This is also needed for IE6:

1.

2.
.navwrap ul{float:left;}
3.


Copy this code and paste it in your HTML
  1. 1.
  2. .navwrap{
  3. 2.
  4. float:left;
  5. 3.
  6. position:relative;
  7. 4.
  8. left:50%;
  9. 5.
  10. }
  11. 6.
  12. .navwrap ul{
  13. 7.
  14. position:relative;
  15. 8.
  16. left:-50%;
  17. 9.
  18. }

URL: http://www.search-this.com/2007/09/19/when-is-a-float-not-a-float/

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.