IE7
Centering a CSS menu without the width (aka Shrink Wrap)
Submitted by NickC on Mon, 09/24/2007 - 09:16
On a recent project, I ran into an issue where the main navigation needed to be centered and flexible enough to add and remove menu items through a CMS. For those of you not familiar with CSS, this creates an immediate problem: you can not center a block element without first knowing its width. The normal technique is to use auto left and right margins (margin: 0 auto), that are then calculated based off the element's width. But what happens when you don't know the width of the element?
- NickC's blog
- Login or register to post comments
- Read more
