Let's say I have a list of items in a container with some padding around them. When I hover over one of the items in that list, I want a "delete" icon to appear in the padding/margin to the right of the item. The problem is, if this the hover event is on the item itself, the delete icon will disappear as soon as you try to click it because you will have stopped hovering on the item. How can I design this so I will not lose the icon when moving the mouse to click on it?
EDIT: My code is in React, so I've provided a simple hypothetical example here:
<div class="container">
<div class="item">
</div>
<i class="icon" />
<div class="item">
</div>
<i class="icon" />
<div class="item">
</div>
<i class="icon" />
</div>
.container {
display: flex;
padding: 24px;
}
.icon {
display: none;
}
.item:hover~.icon {
display: block;
}
EDIT2: I made sure the icon was inside the container, but now it's getting cut off: