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/AVvXsEjTP7z9KOFEpdEgHJN9hz543g2knyL0qmMj2hrBgMR2PSZp0gw2Tan1x9FxbI9iykrlWcuAR0Dz2NCHGVjt9JSWAOQJsNSsT2o_iwmA354SKy1z0VKzm0jONv8xTf1TRQmcx46FDY4IgJ4U/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/AVvXsEiEP_grQPkGKPDuU1P5WsVmUKfcG-lyrU0Iin_J7mJxKsysPk2mD6yDcY-WNkvo0kGgB5dcibh7erQfzFQtsK8u6NFSgvTAZ-7-vO1wiP7ve4qKu-CNuwQwBOWNgXXgonU5yfxlDkzsxFO-/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/AVvXsEiPxLEAjYBgOE5cwe3djji8KswdNB_BelUTZsuC4gFY7pebPIaN0do2eRPwFJvUPB75TZaQmnzza2PGSb0Te1Sc3rjJTh9Qs-NwJGP7Ruchs9ND05GsBEb3D9CpfaWVQCUMs9B4xkkLXmx8/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/AVvXsEjuU5D8Wue7zW0FGT9EZszClyVbLxEd0mx6uGhyNOt0L85TXhOqsyXPC8qJS6-7wZY4qLbEALXolqVBK5YrFdnWFM4MCBRGZmrHFET3b6vN-jKZwhHqNlUdLUOkcXLetITIb22QyONVqUiT/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?"