开发者

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

开发者 https://www.devze.com 2023-01-31 15:11 出处:网络
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.

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;
}


The <li> elements need to have float:left


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)

0

精彩评论

暂无评论...
验证码 换一张
取 消