user3439814
user3439814

Reputation: 3

center this css dropdown menu?

I am new here. Excuse me being a noob. I am a HS student seeking some help.

I cannot seem to paste my code so here's the link for jsfidlle

http://jsfiddle.net/zeusthunder10/WSD9f/6/

<body bgcolor="#D1D1D1">
<div align="center">

Upvotes: 0

Views: 52

Answers (3)

Rick Paul
Rick Paul

Reputation: 76

It looks like you didn't close the ul tag. You will want to put a /ul at the end of your list.

Try putting "display:inline-block;" in your #navbar class

#navbar {
   margin: 0;
   padding: 0;
   height: 1em; 
   display:inline-block;}

Upvotes: 0

Two-Bit Alchemist
Two-Bit Alchemist

Reputation: 18467

You have the style

#navbar li { ... float: left; ... }

so all the li's, you know, float to the left.

You probably want:

#navbar li { ... display: inline-block; ... }

Here's your Fiddle with that swap. IS that what you wanted?

Upvotes: 1

progysm
progysm

Reputation: 1072

One way to center a block element like ul and without width is to use the trick display: table on the #navbar.

Also you need to add the missing </ul>

Jsfiddle fixed: http://jsfiddle.net/WSD9f/8/

Upvotes: 0

Related Questions