html5 - CSS multi level menu with nested list -
i want make pure css multi level menu picture above. have tried tutorial not working me. menu "xxxxx" , "yyyyy" appear below menu "bbbbb" css code below.
what want make 3 level menu picture above.
this html menu:
<span id="nav"> <ul> <li><a href="#">ssss</a> <ul> <li><a href="#">aaaaa</a></li> <li><a href="#">bbbbb</a> <ul> <li>xxxxx</li> <li>yyyyy</li> </ul> </li> </ul> </li> <li><a href="#">ttttt</a></li> <li><a href="#">uuuuu</a></li> </ul> </span>
and minimized css code:
li { list-style:none !important; } #nav, #nav ul { list-style: none; padding:0; margin:0; } #nav li { line-height:20px; float:left; } #nav li ul{ display:none; } #nav ul li ul { margin-top:-3em; margin-left:7em; } #nav ul li:hover ul { z-index:99999; display:list-item !important; position:absolute; margin-top:2px; margin-left:0px; padding: 5px 15px; background: #8ac312; } #nav ul li:hover ul li { float:none; padding: 2px 0px; } #nav ul li:hover ul li > a:before { content: '» '; }
any appreciated make css code working illustration picture above. thanks.
i think problem position relative , absolute. remove style , on own (simpler, uglier). code here jsfiddle
and code is:
css:
ul { padding:0; margin:0; } li { list-style:none; } li > ul { display: none; } li:hover > ul { display: block; } .lvl1 li { margin-right: 10px; display: inline; position:relative; } .lvl2 { position: absolute; } .lvl2 li { position: relative; } .lvl3 { position: absolute; top:0px; left: 50px; }
html:
<span id="nav"> <ul class='lvl1'> <li><a href="#">ssss</a> <ul class='lvl2'> <li><a href="#">aaaaa</a></li> <li><a href="#">bbbbb</a> <ul class='lvl3'> <li>xxxxx</li> <li>yyyyy</li> </ul> </li> </ul> </li> <li><a href="#">ttttt</a></li> <li><a href="#">uuuuu</a></li> </ul> </span>
Comments
Post a Comment