After creating a custom styled button with a hover effect, I noticed an issue where if you happen to hover over a specific spot on the button, it quickly switches between its normal and hover states.
https://i.sstatic.net/uPq1F.gif
This is my code:
button {
height: 34px;
padding: 0 16px;
border-radius: 4px;
margin: 8px;
border: none;
background: red;
color: #fff;
transition: background .2s, transform .2s;
outline: none;
cursor: pointer;
}
button:hover {
box-shadow: 4px 4px 0 0 blue;
transform: translate(-1px, -1px);
}
button:active {
background: green;
box-shadow: 2px 2px 0 0 blue;
}
<button>I am a button</button>
I'm looking for a solution to fix this problem. Any ideas?