0
I’m creating a drop'n down menu in CSS3, but I’m not managing to style the third level.
The CSS is like this:
*{margin: 0; padding:0;}
.menu{width: 100%; height: 50px; background-color:#222; font-family:Arial, Helvetica, sans-serif;}
.menu ul{list-style:none; position:relative;}
.menu ul li{width: 150px; float:left;}
.menu a{padding: 15px; display:block; text-decoration:none; text-align:center; background-color:#222; color:#fff;}
.menu ul ul{position: absolute; visibility:hidden;}
.menu ul li:hover ul{visibility: visible;}
.menu ul ul li:hover ul{visibility: visible;}
.menu a:hover{background-color:#f4f4f4; color:#555;}
.menu ul ul li{float: none; border-bottom: 1px solid #ccc;}
.menu ul ul li a{background-color: #999;}
label[for="bt_menu"]{padding: 5px; background-color: #222; color: #FFFFFF; font-family:Arial, Helvetica, sans-serif; font-size:30px; cursor: pointer; width: 50px; height:50px;}
The HTML is like this:
<nav class="menu">
<ul>
<li><a href="#">Dashboard</a></li>
<li><a href="#">Veículos</a>
<ul>
<li><a href="#">Novos</a></li>
<li><a href="#">Seminovos</a></li>
<li><a href="#">F&I</a></li>
</ul>
</li>
<li><a href="#">Peças</a>
<ul>
<li><a href="#">Balcão</a></li>
<li><a href="#">Oficina</a>
<ul>
<li><a href="#">Mecânica</a></li>
<li><a href="#">Funilaria</a></li>
<li><a href="#">Acessórios</a></li>
</ul>
</li>
</ul>
</li>
</ul>
</nav>
Even the second level is good, but I guess I didn’t know how to set up the third level :/
Thank you very much for the reply Miguel. It worked.
– Webster Moitinho
Ok. Unfortunately, CSS does not provide a way to specify all even or odd levels. So if you want to do a 4th level, where the menu goes down, you have to repeat rules, using
ul > li > ul > li > ul > li
level by level until you reach the desired item. And pro 5th level, the same.– Miguel Angelo