This is a simple code to show and hide content. when the button is hovered the list is shown but when I want to go through my list (for example a or b or c ) it (the list) will be disappeared.something that i need to have is remaining content or my list when i go through it. is there any way to solve it?
.hide {
display: none;
}
.myDiv:hover+.hide {
display: block;
color: red;
}
<ul>
<button class="myDiv">hover</button>
<div class="hide">
<li>a</li>
<li>b</li>
<li>c</li>
</div>
</ul>
I tried it by css code
2
Answers
It’s natural your list gets hidden when you try to go through list items after hovering the button. It’s because once you move your cursor to list items hover event for the button is removed.
So to handle this you need to add hover in the parent in your case
ul
.something like this:
I have re-organize the html structure and updated css for better understanding.
Keep in mind that I have given
display:inline-block
tomyDiv
class restrict 100% width.