html - CSS垂直下拉菜单,当悬停到其他菜单时子菜单显示

标签 html css drop-down-menu hover

执行此操作的正确或最佳方法是什么?我无法修复它:3 当您将鼠标悬停到其他菜单时,会显示成员的子菜单 我的代码有什么问题?我想不通:3 你可以在链接中看到我的代码

http://codepen.io/anon/pen/MaxmvO

<html>
<head>
    <title>Dashboard</title>
    <link rel="stylesheet" type="text/css" href="style.css" />
</head>
<body>

    <header>
        <div class="logo"><a href="#">WORKOUT <span>FITNESS CENTER</span></a></div>
    </header>
    <div id="container">
        <nav>
            <ul>
                <li><a href="#">Walk-In</a></li>
                <li><a href="#">Members</a></li>
                    <ul>
                        <li><a href="#">List of Members</a>
                        <li><a href="#">Subscr</a></li>
                        <li><a href="#">asdasd</a></li>
                    </ul>
                </li>
                <li><a href="#">Sales</a></li>
                <li><a href="#">Inventory</a></li>
                <li><a href="#">Suppliers</a></li>
                <li><a href="#">Reports</a></li>
            </ul>
        </nav>

        <div id="content">
            SOME CONTENT YAY
        </div>
    </div>


</body>
</html>

CSS

 @import url(https://fonts.googleapis.com/css?family=Open+Sans:400italic,400,300italic,300);
*{
    margin: 0;
    padding: 0;
}

body {
    font-family: 'Open Sans';
}

a{
    text-decoration: none;
}

header{
    width: 100%;
    height: 50px;
    border-bottom: 1px solid #858585;
}

.logo {
    float: left;
    margin-top: 9px;
    margin-left: 15px;  
}

.logo a{
    font-size: 1.3em;
    color: #070807;

}
.logo a span{
    font-weight: 300;
    color: #1AC93A;
}

nav{
    width: 250px;
    height: calc(100% - 50px);
    background-color: #171717;
    float: left;
}

#content {
    width: :auto;
    margin-left: 250px;
    height: calc(100% - 50px);
    padding: 15px
}

nav li{
    list-style: none;

}

nav li a{
    color: #ccc;
    display: block;
    padding: 10px;
    font-size: 0.8em;
    border-bottom: 1px solid #0a0a0a;
    -webkit-transition: 0.2s;
    -moz-transition: 0.2s;
    -o-transition: 0.2s;
    transition: 0.2s;
}

nav li a:hover{
    background-color: #030303;
    color: #fff;
    padding-left: 80px;
}

nav ul ul {
    display: none;
}

nav ul:hover ul{
    display: block;
}

最佳答案

试试这个 http://codepen.io/anon/pen/gaEWJw

HTML

 <nav>
    <ul>
        <li><a href="#">Walk-In</a></li>
        <li><a href="#">Members</a></li>
        <li><a href="#">List of Members</a>             
            <ul>
                <li><a href="#">Subscr</a></li>
                <li><a href="#">asdasd</a></li>
            </ul>       
        </li>
        <li><a href="#">Sales</a></li>
        <li><a href="#">Inventory</a></li>
        <li><a href="#">Suppliers</a></li>
        <li><a href="#">Reports</a></li>
    </ul>
 </nav>

CSS

nav ul > li > ul {
    display: none;
}

nav ul li:hover  ul{
    display: block;
}

关于html - CSS垂直下拉菜单,当悬停到其他菜单时子菜单显示,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33784503/

相关文章:

html - 使不同的样式表应用于页面的不同区域

javascript - 选择不带 TR 的表 TD

ajax - 基于选定下拉列表的 django 和 ajax 下拉列表

html - 某些图像在 `background-image:url()` 中不起作用

html - 悬停在下拉列表中时,如何在导航栏上保持悬停效果?

jquery - 选择的harvethq动态调整宽度

javascript - 如何添加新选项以选择是否使用 jQuery 更改单选按钮

html - 使页脚保持在没有主体的底部 { 高度 : 100% }

css - Bootstrap : Aligning two buttons on the same row

html - 如何为下拉选择选项添加渐变背景?