Sent by Rick Pasotto on 31 October 2004 23:11
On Sun, Oct 31, 2004 at 10:29:22PM +0000, Christian Heilmann wrote:
> Robert Dumas wrote:
>
> >I'm creating the new version of my site and I'm trying to get the
> >navigation centered. You can see a rough of the header and navigation
> >at http://obnoxio.us/dumpbox/rdo/ (the stylesheet is "layout.css"). I
> >want the navigation to be centered in the navigation bar, but I don't
> >know how.
> >
> >Can someone help me with this?
> >
> You need to set a width to the navigation and then set its margin to 0
> auto. For older IEs you also need to set the text-align of the
> parent element to center. The auto margin will also mean that you'll
> have to apply the background image to the parent element. The
> easiest option is to add a DIV around the navigation UL and make the
> changes to that one:
>
> <div id="navigation">
> <ul.......>
> </div>
>
> and
>
> #navigation{
> text-align:center;
> background: transparent url(images/navbarbg.gif) repeat-x;
> }
> #navigation ul{
> width:30em;
> margin:0 auto;
> }
The problem with this is that you don't know what width to use. If the
user resizes the font then the menu breaks terribly. As much as I'd like
to have a centered nav bar I've given up on it because of this.
Of course you could probably adjust on the fly with javascript, but
that's quite clumsy.
--
"Nobody in the game of football should be called a genius. A genius is
somebody like Norman Einstein." -- Joe Theisman, Former quarterback
Rick Pasotto [EMAIL-REMOVED] http://www.niof.net
______________________________________________________________________
css-discuss [EMAIL-REMOVED]]
http://www.css-discuss.org/mailman/listinfo/css-d
List wiki/FAQ -- http://css-discuss.incutio.com/
Supported by evolt.org -- http://www.evolt.org/help_support_evolt/