How To Create An Unordered List Inside An Unordered List In A List Menu?
On my page, I'm trying to create an unordered list within an unordered list in my menu so that there is a second dropdown menu. The problem is that the second dropdown menu display
Solution 1:
The key to getting the sub-menu working is to use the child combinator (>
) to target direct descendants.
A child combinator describes a childhood relationship between two elements. A child combinator is made of the "greater-than sign" (U+003E, >) character and separates two sequences of simple selectors.
(http://www.w3.org/TR/css3-selectors/#child-combinators)
The following changes are required:
- Add the
.menu li ul ul
settingleft: 100%;
andtop: 0;
. This will tell all sub-menus to be positioned against the right edge of its parent menu. - Change
.menu li:hover ul
to.menu li:hover > ul
. This will ensure that only the direct childul
is shown when the user hovers over the parentli
. - Change
.menu li ul a:hover, .menu li ul li:hover a
to.menu li ul li:hover > a
. This will ensure that only the direct childa
s are highlighted when the user hovers over the parentli
.
.menu {
border: none;
border: 0px;
margin: 0px;
padding: 0px;
font: 67.5%"Lucida Sans Unicode", "Bitstream Vera Sans", "Trebuchet Unicode MS", "Lucida Grande", Verdana, Helvetica, sans-serif;
font-size: 14px;
font-weight: bold;
}
.menuul {
background: #333333;
height: 35px;
list-style: none;
margin: 0;
padding: 0;
}
.menuli {
float: left;
padding: 0px;
}
.menulia {
background: #333333url("https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEheYhgUgsP5xO_htXoAvlMEJkykWzHwGyG8V6eC4P3ndaGB4XOYtf5HOk2CJk5nj_aZ0UdbNsphwBL47TK-0EH-8io0wvE6q8We2sHexWoY4TNG8SRpzg7S7qlDpHRamXoCyUjUq5xFhviP/s1600/seperator.gif") bottom right no-repeat;
color: #cccccc;
display: block;
font-weight: normal;
line-height: 35px;
margin: 0px;
padding: 0px25px;
text-align: center;
text-decoration: none;
}
.menulia:hover,
.menuulli:hovera {
background: #2580a2url("https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjDIz8nf5Xy8uRWhRV14jF6WOdO6eWS6y7y6T_yIitX0rFuluLL-90veJDVYf6l03TtWZbQuyQSoi9F6OIWj5TnTVFJu-B4MGetLGGFnYp1LLF0FbtMBmh79cpMJXE28nqEFT59YJsdQ2ry/s1600/hover.gif") bottom center no-repeat;
color: #FFFFFF;
text-decoration: none;
}
.menuliul {
background: #333333;
display: none;
height: auto;
padding: 0px;
margin: 0px;
border: 0px;
position: absolute;
width: 225px;
z-index: 200;
}
.menuliulul {
top: 0;
left: 100%;
}
.menuli:hover > ul {
display: block;
}
.menulili {
background: url('https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiyFxblYO69jvwK26u6MFQXbaflpqIVj3PpqlRNYulzWWEUBwlDD-0HQho20UD4S7ttcEa4pRVu2td5J3y1Aic1q73kzFkTzVypXdPJjSxXD_CbH-Bvi7Jlvj8WUN8TCPgTYlgiasDRJL1n/s1600/sub_sep.gif') bottom left no-repeat;
display: block;
float: none;
margin: 0px;
padding: 0px;
width: 225px;
}
.menuli:hoverlia {
background: none;
}
.menuliula {
display: block;
height: 35px;
font-size: 12px;
font-style: normal;
margin: 0px;
padding: 0px10px0px15px;
text-align: left;
}
.menuliulli:hover > a {
background: #2580a2url('https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgSNhscX7gQ-726OSfPQUowK76iOF_Yqgrq5UW2Ska0R0SdeNryO-z7em6tnJUub9dmgKoB-533WxhoHdzAcaZzEvT-wp7JhgtNXwI2ccKUNEsHMZdSIEhGjtbVvvcthZxxJW79TIaZPDXk/s1600/hover_sub.gif') center left no-repeat;
border: 0px;
color: #ffffff;
text-decoration: none;
}
<divclass="menu"><ul><li><ahref="/search/label/game">Games</a><ulid="1"><li><ahref="/search/label/minecraft">minecraft</a><ulid="2"><li><ahref="/search/label/Project">Projects</a></li><li><ahref="/search/label/Texture Pack">Texture Packs</a></li><li><ahref="/search/label/Skin">Skins</a></li><li><ahref="/search/label/Mod">Mods</a></li><li><ahref="/search/label/Other">Other Stuff</a></li></ul></li></ul></li></ul></div>
Post a Comment for "How To Create An Unordered List Inside An Unordered List In A List Menu?"