1

Ok. So I have started to build a website, and I have tried to build a dropdown menu using css and html. The hover function for the submenu works. My only issue is, when you mouse over the menu to get to the submenu, I can't figure out how to change the font to black so it is visible.Here is a page where I am testing the code: http://mcbtaytest.zymichost.com/

Here is my code:

CSS:

body {margin:0;
    padding:0;
    background:#000000
}

.image{
    border: none;
    border:0px;
    margin:0px;
    padding:0px;
    z-index: -1;
}


.menu{
    border:none;
    border:0px;
    margin:0px;
    padding:0px;
    font: 67.5% "Lucida Sans Unicode", "Bitstream Vera Sans", "Trebuchet Unicode MS", "Lucida Grande", Verdana, Helvetica, sans-serif;
    font-size:14px;
    font-weight:bold;
    z-index:2;
}
.menu ul{
    background:#FFFFFF;
    height:50px;
    list-style:none;
    margin:0;
    padding:0;
    -webkit-border-radius: 15px;
    -moz-border-radius: 15px;
    border-radius: 15px;
    -webkit-box-shadow: inset 0px 16px 0px 0px rgba(255, 255, 255, .1);
    -moz-box-shadow: inset 0px 16px 0px 0px rgba(255, 255, 255, .1);
    box-shadow: inset 0px 16px 0px 0px rgba(255, 255, 255, .1);
}
.menu li{
    float:left;
    padding:0px 0px 0px 15px; 
}
.menu li a{
    color:#000000;
    display:block;
    font-weight:normal;
    line-height:50px;
    margin:0px;
    padding:0px 25px;
    text-align:center;
    text-decoration:none;
}
.menu li a:hover{
    background:#000000;
    color:#FFFFFF;
    text-decoration:none;
    -webkit-box-shadow: inset 0px 0px 7px 2px rgba(0, 0, 0, .3);
    -moz-box-shadow: inset 0px 0px 7px 2px rgba(0, 0, 0, .3);
    box-shadow: inset 0px 0px 7px 2px rgba(0, 0, 0, .3);
}
.menu ul li:hover a{
    background:#000000;
    color:#FFFFFF;
    text-decoration:none;
}
.menu li ul{
    display:none;
    height:auto;
    padding:0px;
    margin:0px;
    border:0px;
    position:absolute;
    width:200px;
    z-index:200;
}
.menu li:hover ul{
    display:block;      
}
.menu li li {
    display:block;
    float:none;
    margin:0px;
    padding:0px;
    width:200px;
    background:#FFFFFF;
    /*this is where the rounded corners for the dropdown disappears*/
}
.menu li:hover li a{
        background:none;
}
.menu li ul a{
                display:block;
        height:50px;
        font-size:12px;
        font-style:normal;
        margin:0px;
        padding:0px 10px 0px 15px;
        text-align:left;
}
.menu li ul a:hover, .menu li ul li:hover a{
    border:0px;
    color:#ffffff;
    text-decoration:none;
    background:#000000;
    -webkit-box-shadow: inset 0px 0px 7px 2px rgba(0, 0, 0, .3);
    -moz-box-shadow: inset 0px 0px 7px 2px rgba(0, 0, 0, .3);
    box-shadow: inset 0px 0px 7px 2px rgba(0, 0, 0, .3); 
}   

HTML:

<div class="image">   
    <img src="/Resources/img/Header.png" width=100% style={margin:0;padding:0;}/></img>
</div> 
<div class="menu">
    <ul>
        <li><a href="#" >Home</a></li>
        <li>
            <a href="#" id="current">About</a>
            <ul>
                <li><a href="#">Company Info</a></li>
            </ul>
</div>

I for some reason can't figure out how to solve this.

4

3 回答 3

1

我对你的 html 做了一些更改(它被破坏了,一些元素是多余的)和你的 css (删除了一些选择器并重写了其他的)。

这和想要的一样吗?

于 2012-08-29T06:33:34.083 回答
1

编辑:

更改以下行

.menu ul li:hover a

用这条线;

.menu ul li:hover > a

现在更具体了。

看演示

于 2012-08-29T06:15:01.363 回答
0

补充:color:#000_.menu li:hover li a

.menu li:hover li a{
    background:none;
    color:#000;

 }
于 2012-08-29T06:21:49.527 回答