Previous Message
Next Message

Trick for centering menu

Sent by Paul Novitski on 18 February 2010 19:07


At 2/18/2010 10:23 AM, Neil Hunt wrote:
>Trying to center bottom navigation menu in footer of webpage. Menu ignores
>centering and wants to left justify rather than center in a width defined
>area. Any tricks to force the centering? It was suggested that I manually
>center it by increasing the padding but I thought there had to be a better
>way around this. Any ideas?


There is a useful wiki that accompanies this listserve. Check this out:
http://css-discuss.incutio.com/?page=CenteringBlockElement

Briefly, if you know the width of your menu you can declare that in 
your stylesheet and then use a number of techniques for centering, 
including setting margins left & right to 'auto' or using the left: 
50%; margin-left: -NNNpx where NNN is half your meun width.

If you can't predict the width, you can try declaring the menu items 
inline and use text-align: center.

If you can't use inline, say because it doesn't give you enough 
control over margins & padding, you can try table-cell and sacrifice 
cross-browser support. (It's easy to serve separate stylesheets to 
various versions of IE using conditional comments.)

Regards,

Paul
__________________________

Paul Novitski
Juniper Webcraft Ltd.
http://juniperwebcraft.com 

______________________________________________________________________
css-discuss [EMAIL-REMOVED]]
http://www.css-discuss.org/mailman/listinfo/css-d
List wiki/FAQ -- http://css-discuss.incutio.com/
List policies -- http://css-discuss.org/policies.html
Supported by evolt.org -- http://www.evolt.org/help_support_evolt/
Previous Message
Next Message

Possibly related: