0
<div id="nav">
    <ul id="rightMin">
        <li id="selectedmenu" onclick="location.href='index.php'">main</li>
        <li onclick="location.href='aboutus.php'">about</li>
        <li><a href="#">contact us</a></li>
    </ul>
</div>

CSS:

#selectedmenu {
    display:inline;
    float:right;
    /*padding: 2px 7px 0px 7px;*/
    height: 35px;
    background: url('../images/selected.png') repeat-x;
    cursor: pointer;
    text-align: center;
    line-height:35px;
    padding: 0 5px 0 5px;
    color: white;
}
div#nav ul li {
    display:inline;
    float:right;
    /*padding: 2px 7px 0px 7px;*/
    height: 35px;
    cursor: pointer;
    text-align: center;
    line-height:35px;
    padding: 0 5px 0 5px;
}

div#nav ul li:hover {
    background: #232323;
    color:#fff;
}

The element with the ID selectedmenu takes CSS #selectedmenu but when hovering it takes div#nav ul li:hover. how can i make it sticks with #selectedmenu

4

3 回答 3

1
div#nav ul li#selectedmenu:hover {
    add your css rules here...
}
于 2012-05-09T02:43:39.870 回答
0

Give selectedmenu a higher precedence:

div#nav ul li#selectedmenu {
     ...
}
于 2012-05-09T02:37:41.807 回答
0

just change it every time you hover it, try this:

div#nav ul li #selectedmenu:hover{ /* the style for #selectedmenu*/ }

hope this helps..

于 2012-05-09T02:50:44.877 回答