-3

我有一个我已经构建的菜单目前运行良好,我正在尝试添加当鼠标悬停在菜单项上时出现的子菜单项。有谁知道如何做到这一点?

<div id="menu">
            <a  href="#" >Home</a>
            <a  href="#">Submit New Record</a>
            <a   href="#">Sales by Salesperson</a>
            <a   href="#">Total Sales</a>
            <a  href="#" >Sales by Issue</a>
            <a  href="#" >Sales by Ad Size</a> 
            <a  href="#" >Add New User</a>  
            <a href="#">Edit Record</a> 
            <a href="#">Logout</a>
            </div></center>
<style>
#menu{
background-color:#3F9AD1;
height:75px;
width:1206px;
}

#menu a{
border-style:solid;
border-width:2px;
border-color:white;
padding-top: 20px;
float:left;
display:block;
width:130px;
height:70px;
text-decoration:none;
color:white;
text-align:center;
font-family: Arial;
/*box-shadow: 0 -7px 22px 6px #000000 inset;*/
}

#menu a:hover{
    color:#3F9AD1;
    background-color:white;

#html { 
height: 100%; 
margin-bottom: 0.01em;
overflow-y: scroll;
}

</style>
4

2 回答 2

3

我通常这样做:

<ul class="menu">
    <li>Main Menu Item
        <ul class="submenu">
            <li>Sub Menu Item</li>
        </ul>
    </li>
</ul>

然后像这样的CSS:

ul.submenu {
    display: none;
}

li:hover ul.submenu {
    display: block;
}
于 2013-04-08T21:04:15.953 回答
1

你可以去这里学习使用他们的示例教程。这很容易。只处理你的悬停状态。

http://line25.com/tutorials/how-to-create-a-pure-css-dropdown-menu

于 2013-04-08T21:01:11.173 回答