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/AVvXsEg60v_IRP8557TdYxgHQuM8pGuKu036PmvePHmyqyFoxNtigf8WE1X4Caj7_jgvB06J7ujXABVB-Scg5Q1hyphenhyphenym472JLcg0UxzqzYsNaEejexGQLK0BFIkvSnPoJ1Km-cEIoUTOtfl9WEljY/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/AVvXsEhpfmug5QZvRz3VYouGm_2FzUoHXxwFbgBA413bywaIxxpasZ7hFa2Cj1EF5xlVipgQdT-96L7Tpm1IV5h5DixDqAeeR-ih8d1Lz11MHkvPxHXlSDZPGlQQYCt7Y91yLzOg_k6LsVBfApU3/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/AVvXsEiy5rarQKyEhDRzpF0Isxg745Ii2Zhd4vGmmn5zuyk1T70pCS2iU1FFeuGROIxZcyHWsWLcH0PlQCvBWK6jYEKIh4jkQs9fdj-srb60FQerGzst9q9x7x7Tu221PsOUNwkdEjqCgyDBKuHS/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/AVvXsEgYHrBX2GgRhJCkfo0TBemYIyOO_la9ouVGnTk8RZ2QHqkebzzrFvjjbTy0L-aLajtD7seLsgjjjCWww6pe89IW9jWVl7GaHiGOiDeFa2QzTB6ESBFDxI7icWPliTxFOjEi2nm1wWQ67boe/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?"