In both I asked about How to make dropdown which is working fine Now I want to make dropdown more then one level but that is not working according to my requirement
this is my jsfiddle.net http://jsfiddle.net/vngx/u94688bo/3/
You only seem to have one level in that dropdown which doesn’t seem to be working anyway. You need to add the following code to get that menu working.
#header li {position:relative;}
#header li:hover > ul {
display:block;
position:absolute;
left:0;
top:100%;
margin:0;
padding:0;
}
#header li ul li {display:block;float:none;}
Dropdowns are pretty straightforward and you just set postion:relative on the parent list and position:absolute on the nested ul. When the list is hovered you show the ul.
e.g.
#header li:hover > ul {show it where you want}
For more levels you can’t show the menu below so you then place it to the side so for a further nested menu you would target the next layer like so:
#header li li:hover > ul {
display:block;
position:absolute;
left:100%;
top:0;
margin:0;
padding:0;
}
Dropw down menus are a bit awkward in a responsive site and of course there is no hover on mobile and I much prefer click menus which are easier for those with poor motor skills to use.
By default the nested ul was set to margin-left:-999em; which hides it off the side of the screen and out of the way but still available for screen readers and spiders (unlike display;none).
When you hover a parent list item you then bring the nested ul into view. As you have multiple nested menus you must olny bring the immediate child into view and not all nested menus.
So li:hover > ul will show a nested ul but not all nested uls.
<ul id="header">
<li><a href="#">About Us</a></li>
<li><a href="#">Services</a> <!-- hover this parent 'li' and show the nested ul -->
<ul>
<li><a href="#">WebDesign </a> </li>
<li><a href="#">Android App »</a>
<ul><!-- however don't show me yet -->
<li><a href="#">Sub Sub link 1</a></li>
<li><a href="#">Sub Sub link 2</a></li>
<li><a href="#">Sub Sub link 3</a></li>
</ul>
etc....
Now:
#header li li:hover > ul {
This is saying that from 2 levels deep when you hover the list item at that level show the nested ul but this time move it to the side so we can see it because we no longer want to drop downwards.
The basis of a hover menu is that you hide the ul that is nested within a list item and then when you hover the list item you bring the ul back into view. It’s as straight forward as that although it probably seems more complicated in the context of multiple nested lists.