3 replies [Last post]
yourgrace
yourgrace's picture
User offline. Last seen 7 years 6 weeks ago. Offline
rank Regular
Regular
Timezone: GMT+4
Joined: 2005-04-10
Posts: 12
Points: 0

First, I would like to say that I did, indeed RTFM. I am not sure I totally understand it however. I noticed that the gurus here are very patient explaining things, and boy, have I been searching and reading posts!
With that said, my horizontal list menu will. not. center. entirely, even in the much-loved Firefox. It sort of centers, but I had to adjust my
margins so it wouldn't look so off kilter.
I think that may be a simple fix, but durned if I can find it.
Now, since I tried to code for submenus, they have displaced the menu onto two lines instead of one. Taking out a list item that I could live without did not make a difference. AND
I cannot seem to position my submenu so it will attach to the "samples" list item. I really have spent hours trying to learn this.
I am creating a three column CSS layout for another site,
this is how the centering is off when the list items are not displayed in two rows
http://unix12.vizaweb.com/~yourgrac/demo.html

this is the practice before I implement the navigation on the first site, you can see how it has gone horribly awry.

http://unix12.vizaweb.com/~yourgrac/demoP.htm

I had (have) working dhtml menubars on the original portfolio site, but it had a whole lot of javascript and I wanted a cleaner code.
I would so appreciate one of your generous and patient explanations of how I have failed.

gary.turner
gary.turner's picture
User offline. Last seen 17 min 1 sec ago. Offline
rank Moderator
Moderator
Timezone: GMT-5
Joined: 2004-06-25
Posts: 7928
Points: 1767

CSS horizontal menu wont center (submenu sucks)

When you display the list items as inline, you must use {text-align: center;} to center them. I moved some properties to their correct elements.

 
.nav { 
    text-align: center; 
    } 
 
.nav ul { 
    margin: 0; 
    padding: 0; 
    list-style: none; 
    } 
		 
.nav li {  
    display:inline; 
    line-height: 30px; 
    }

As of html4, 1999, 'align' is no longer an attribute of any element other than <caption>. As with the <li>s, you must use css.
 
.header { 
    position: relative; 
    text-align: center; 
    }

cheers,

gary

Unplanned code results in a tangled wad of brain-cramping confusion.

There are enough html & css demos and tutorials to be interesting. Please visit.

yourgrace
yourgrace's picture
User offline. Last seen 7 years 6 weeks ago. Offline
rank Regular
Regular
Timezone: GMT+4
Joined: 2005-04-10
Posts: 12
Points: 0

CSS horizontal menu wont center (submenu sucks)

Gary, your solution was elegant and simple.
It worked, even in IE. Thank you so much! *doing a happy dance*
Sherry.

DCElliott
DCElliott's picture
User offline. Last seen 22 weeks 4 days ago. Offline
rank Leader
Leader
Timezone: GMT-4
Joined: 2004-03-22
Posts: 828
Points: 0

CSS horizontal menu wont center (submenu sucks)

Ah - another Halifax CSSer, you have come to the right place for CSS help - welcome to the club. Make sure you read the blog section and the how-tos and the various directions on how to get help here and elsewhere. That'll keep you from embarrassing the rest of us Haligonians (and, yes, folks - that is how it is said, just like Liverpudlians and other quaint ways to refer to people from places with names you can't add an 'er' or an 'an' to)

DE

David Elliott

Before you ask
LearnXHTML|CSS
ValidateHTML|CSS