Reputation: 245
What is the proper or best way to do this? I can't fix it :3 The submenu of members shows when you hover to the other menus What's the problem with my code? I can't figure it out :3 you can see my codes in the link
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;
}
Upvotes: 1
Views: 2866
Reputation: 3921
You need to target the specific element and then show the sub menu. I added an id
to this li
to make it easier to target and got rid of the </li>
so the ul
is inside li#members
.
<li id="members"><a href="#">Members</a>
<ul>
<li><a href="#">List of Members</a></li>
<li><a href="#">Subscr</a></li>
<li><a href="#">asdasd</a></li>
</ul>
</li>
nav #members:hover ul{
display: block;
}
Upvotes: 0
Reputation: 122115
Try this 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;
}
Upvotes: 1