html - Dropdown menu using CSS not displaying the menu on hover -
i trying dropdown menu appear when user hovers on about
menu, see http://jsfiddle.net/bpabc/
html:
<nav> <ul> <li> <a href="#">home</a> </li> <li> <a href="#">about</a> <ul class="sub"> <li>one</li> <li>two</li> <li>three</li> </ul> </li> <li> <a href="#">contact</a> </li> </ul> </nav>
css:
nav > ul { margin: 0; padding: 0; display: table; width: 100%; height: 100%; } nav > ul > li { display: table-cell; list-style: none; padding: 0; margin: 0; text-align: center; } nav > ul > li { color: red; } nav > ul > li > ul.sub { display: none; } nav > ul > li a:hover ul.sub { display: block; }
the .sub
ul not displaying when hover on about. assume have made error last 2 rules can't work out.
you need change selector nav > ul > li:hover ul.sub
because ul.sub
not child of a
nav > ul > li:hover ul.sub { display: block; }
Comments
Post a Comment