My goal is to create a button that moves up 5px when hovered over.
I've successfully implemented this using transitions. However, the issue arises when hovering on the lower part of the button - as I move my mouse (I suspect it checks :hover on mouse update, but CSS is new to me...), the button shifts up causing it to no longer be hovered, resulting in a flickering effect.
.btn {
display:inline-block;
transform: translate(0px,0px);
transition: transform 50ms ease ;
}
.btn:hover {
transform: translate(0px,-5px);
transition: transform 50ms ease ;
}
<button class="ui button btn"> That rocks!</button>
How can I avoid this behavior? The only solution I found was to use display: inline-block, which didn't solve the issue.
Additionally, I attempted using a container div, but the problem persists.