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/AVvXsEh47ToBZpz88Kfu65YD7WiWYDUxBiiwghwc71K-a8gZRDNEhXlUi4TWHA49CWH4IH1BUiOvS62FGaFl9h4839flGkfPH1zF1lvJU3ucXY6JtJZ9X5Jd42JzXF1dOgEN9GhXCKfl0o_pO9Xg/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/AVvXsEggrv63w-velFLUubuWkCqAZW07ajikRh3NGPGyQe3e0awYL6A7gSBhwlDKwCPDr6dpcLc2fvgkH8QEZAjSGMpgZ2PrShtlVV4LkmlzTzzaDRMK8op0AJdNoslRUC8O94KmqmT0TxPAL3fU/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/AVvXsEhxmibjxysBI72C0Gvv-s08vg3bZ7zK504MyD6decViHdJWxhyphenhyphen3YA6D66NyR3yFe2jZbjTNu3yuKXV5zpkzJLbP1STjgWV4iC_oZsVK0C83eHbbvSddELT8e5ZUThlEPi-B1tNJcdyR3F7c/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/AVvXsEj0xS6NJBXGm-TRj3o-OaGtahxxob31RQgG44rm4huaD_TVur9TGfeRVbUWxa_Bbv7SJa0un2IFo0UcMJ10j0xDqbqKQsU8sCg4WfyZiYnaPxEEjxwA7QprMRcl6tbkekLFNviltSfElApH/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?"