r/csshelp • u/ArturUwU • Jun 13 '21
Weird css hover with movement
Is there any way to increase the "mouse area" of a element? I've made a div that goes up a bit after it has been hovered, but it gives results like this: https://imgur.com/gallery/Hl7I5bG when you put your cursor underneath. So is there any way to increase mouse area? Thanks in advance :)
3
u/be_my_plaything Jun 13 '21
Without seeing your current code I can't say for sure, but my guess is you have the hover attached to the div,so when you hover at the bottom the div is moving up and away from the cursor so it ends the hover, which makes it fall back to the cursor and restart the hover, which causes the flickering.
You could give each div a parent with the hover on the parent..
.parent:hover .child{
margin-top:-10px;
} This way as the div you see moves up you are still hovering on the parent which doesn't move
2
4
u/Zmodem Moderator Jun 13 '21
Put them in a container that triggers the effects when the containers are hovered, rather than the direct elements. I'm on mobile, so I hope this dummy example helps:
HTML
CSS