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/AVvXsEiBcuLr5Zw9fdilNzaP9BXD0jQF0duQ1TKTxvJtJEhvDGYVQpVPZvvK7aAOX29JMydTEGyBmcRwJQFXIhFlAGPTlC4AHJG14mxDKM-OOKi7fRXvUwrDQFPSl69H65toQXurSVrLbmfyPWCN/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/AVvXsEg6ViHNLQIxPSegOzgXePkyDU4kIbhhHiRMP1VQGc7_4eCbLAFpGgMcqZ5fMl0kRnS8pqjlygIJRCSuft1J1HL6nZjqoZm3XNRgrz4QTmxZJuPesVhy2D8zq96FAttorRI7XM-vF5ZZKgnu/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/AVvXsEhN2OTdwkzQ69HMC0QBj53rrlqgJh05OL7TtHESYFEQSG9M0AISwCCZ1ExTxXaXxsUFjrK07qh_lsXhyphenhyphenSzvBr3LToKABQCq4ii7D9f6uneqIl9TCfbcjchSq8WFwv09FpXmEXiywQ0NPnD7/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/AVvXsEjqSY4s7OB34HgOl9JQznLrL_RqxrZrHS-NaNNGbOlShF_eur7L4SY5VXVqaGop2iYpvqPimNu231ioS50EXhN0cJY3HtmD-OyayOYxs9HjiqkqTOs1af0aouejLgymNJWZZ6qJDuxonLrC/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?"