0
Good afternoon, I have a "menu" and instead of being an item inside the other, I am using the ~ to be able to give Hover in the element after which I passed the mouse, then, this element opens, only that, as it is not "inside", when taking the mouse from the element that receives the effect of Hover, this later element closes.
Let me give you a simple example:
ul {
display: flex;
}
li {
margin: 15px;
flex-basis: 50%;
list-style: none;
}
a {
border: 1px solid;
border-radius: 5px;
display: block;
padding: 10px;
box-shadow: -3px -3px 0 2px blue;
}
.sss {
display: block;
margin: 10px 0 0 0;
border: 1px solid red;
padding: 10px;
border-radius: 5px;
width: 80%;
float: right;
box-shadow: -3px -3px 0 2px red;
display: none;
}
a:hover ~ span {
display: block;
}
<ul>
<li>
<a href="#">Menu</a>
<span class="sss">Meu primeiro link</span>
</li>
<li>
<a href="#">Menu</a>
<span class="sss">Meu segundo link</span>
</li>
</ul>
As you can see, the span element even appears, but if I take the mouse from the li element, that span element disappears, I need to leave it open...
You basically answered the question. If you want the effect
hover
is maintained, you need the element to be displayed inside the element itself. For example, why notli:hover > span
?– Woss
Anderson, thank you, but I really need you to stay inside even if you’re not inside, is that possible? Because as this "menu" I can not touch the structure of it (Saas platform), I would have to do something in this sense.
– Lucas de Carvalho