0
I have the following code:
.classes {
margin-top: 80px;
height: auto;
background-color: red;
}
.classes ul {
list-style: none;
float: left;
position: absolute;
}
.classes ul li {
position: relative;
}
.classes button {
display: block;
border: none;
text-align: left;
}
.classes ul li ul {
position: absolute;
display: none;
left: 100%;
top: 0;
border-left: 3px solid black;
padding-left: 0px;
}
.classes ul li:hover ul {
display: block;
}
.classes button {
padding: 15px;
width: 100%;
background-color: #7D8A9B;
border-bottom: 2px solid #ccc;
}
.classes .sessoes {
border: none;
}
/*Móveis*/
.sessao1:hover {
color: white;
border-bottom: 2px solid #7ec8fc;
}
.moveis:hover {
background-color: #7ec8fc;
color: white;
}
/*Roupas*/
.sessao2:hover {
border-bottom: 2px solid #82edaa;
}
.roupas:hover {
background-color: #82edaa;
}
/*Outros*/
.sessao3:hover {
color: white;
border-bottom: 2px solid #f34f4f;
}
.outros:hover {
background-color: #f34f4f;
color: white;
}
/*Cozinha*/
.sessao4:hover {
border-bottom: 2px solid #E6E0D4;
}
.cozinha:hover {
backgr
<nav class="classes">
<ul>
<li>
<!-- Sessão dos Móveis -->
<button class="sessao1">Móveis</button>
<ul>
<li>
<button class="sessoes moveis" id="linkCadeira" onclick="cadeira()">Cadeiras</button>
</li>
<li>
<button class="sessoes moveis" onclick="mesas()">Mesas</button>
</li>
<li>
<button class="sessoes moveis" onclick="sofas()">Sofásas</button>
</li>
<li>
<button class="sessoes moveis" onclick="instantes()">Instantes</button>
</li>
<li>
<button class="sessoes moveis" onclick="armarios()">Armarios</button>
</li>
</ul>
</li>
<li>
<!-- Sessão das Roupas -->
<button class="sessao2">Roupas</button>
<ul>
<li>
<button class="sessoes roupas" onclick="bones()">Bonés</button>
</li>
<li>
<button class="sessoes roupas" onclick="camisas()">Camisas</button>
</li>
<li>
<button class="sessoes roupas" onclick="shorts()">Shorts</button>
</li>
<li>
<button class="sessoes roupas" onclick="calcados()">Calçados</button>
</li>
</ul>
</li>
<li>
<!-- Sessão dos Outros -->
<button class="sessao3">Outros</button>
<ul>
<li>
<button class="sessoes outros" onclick="quadros()">Quadros</button>
</li>
<li>
<button class="sessoes outros" onclick="abajur()">Abajur</button>
</li>
<li>
<button class="sessoes outros" onclick="luminarias()">Luminárias</button>
</li>
<li>
<button class="sessoes outros" onclick="tapetes()">Tapetes</button>
</li>
</ul>
</li>
<li>
<!-- Sessão dos Itens de Cozinha -->
<button class="sessao4">Itens de Cozinha</button>
<ul>
<li>
<button class="sessoes cozinha" onclick="panelas()">Panelas</button>
</li>
<li>
<button class="sessoes cozinha" onclick="talheres()">Talheres</button>
</li>
<li>
<button class="sessoes cozinha" onclick="fogoes()">Fogões</button>
</li>
<li>
<button class="sessoes cozinha" onclick="microondas()">Microondas</button>
</li>
</ul>
</li>
</ul>
</nav>
And I want to know if it is possible and if it is how I can make the effect of the main buttons Hover remain when passing the mouse over the secondary buttons, because when you pass the mouse over the "subitens" the effect of the main items disappears. Note: Only with html and css, if no other solution can be shown.
Why use
button
? I think usinga
will become more semantic for a menu.– Woss
I’m using this side menu with Buttons because if you observe they have an onClick function that makes appear a div and disappear with another case is already appearing, if I were to use the tag "a" I would have to put inside the href a "#" causing the user to return to the top of the site by clicking or otherwise placing "javascript:;" inside href which would leave the obstructive code, which neither of the two options would be viable.
– Lone Tonberry
As far as I know, it is not possible using css only, you will have to resort to javascript to add/remove the correct classes to the parent element. I’ve heard that you could only do it with CSS using
pointer-events
, but I’m not sure.– Alisson