MrBubbles
MrBubbles

Reputation: 53

CSS Horizontal Menu: display: inline; won't work

I'm on Chrome/Firefox. I've read several tutorials and questions here too on this topic.

I have a UL containing LI. I set the LIs to "display: inline;", but they won't. They're still vertical.

What am I doing wrong?

Thx.

Here's my css:

  .menu{
    width: 100%;
    padding: 0px;
    margin: 0px;
    outline: 1px solid grey;
    background-color: #f6f6f6;
    font-size:100%;
}

.menu ul{
    float: left;
    list-style: none;
    margin: 0px;
    padding: 0px;
    background-color: #f6f6f6;
}

.menu li ul{
    display: none;
    height: auto;
    padding: 0px;
    margin: 0;
    background-color: #f6f6f6;
    outline: 1px solid gray;
    position: absolute;
    z-index: 200;
    left: 20px;
    top: 30%;
}

.menu li:hover ul{
    display: block;
}

.menu li:hover{
    background-color: #005ea2;
}

.menu li{
    display: inline;
    padding: 0;
    margin: 0;
    border-bottom: 1px dotted grey;
}

.menu ul li:last-child{
    border: none;
}


.menu a{
    display: block; 
    color: #333333;
    text-decoration: none;
    margin: 0px;
    margin-left: 5px;
}

.menu a:hover{
    color: white;
    background-color: #005ea2;
}

.menu .menu_header{

    color: #333333;
}

.menu .menu_header a:hover{
    color: white;
}

Upvotes: 1

Views: 14177

Answers (2)

Andreyu
Andreyu

Reputation: 454

The <li> elements need to have float:left

Upvotes: 3

Agos
Agos

Reputation: 19460

first of all you might consider adding the relevant HTML to your answer, to help answerers understand your situation better.

I can spot several strange things that might be related to your problem.

First, the li ul selector are not very useful: it's more likely that you meant the opposite, ul li.

Second, I see that on hover you have something changing to display: block. This is a very strange behavior to have on hover, are you sure?

Third, I see that you have a { display: block }. This does not play nicely if its container is display: inline so you might want to switch to display: inline-block for the container (which is what I would suggest for an horizontal menu anyway)

Upvotes: 0

Related Questions