I want to make a button pressing animation using .div:focus
pseudo-class. But it seems to only work once after the browser is refreshed.
I can't figure out how to make it effective every time when the user presses the button... Below are the HTML and CSS.
.icon {
text-decoration: none;
display: flex;
align-items: center;
justify-content: center;
height: 220px;
width: 220px;
margin: 15px 0px;
background-color: #f2f3f7;
box-shadow: 0.6rem 0.6rem 1.2rem #d2dce9, -0.5em -0.5em 1em #ffffff;
border-radius: 3rem;
overflow: hidden;
}
.icon img {
width: 86%;
height: 86%;
border-radius: 50%;
}
.icon:focus {
animation: pressbtn 0.2s ease-in-out;
}
@keyframes pressbtn {
0% {
box-shadow: inset 0.6rem 0.6rem 1.2rem #d2dce9, inset -0.5em -0.5em 1em #ffffff;
}
100% {
box-shadow: none;
}
}
<a href="#" class="icon">
<img src="https://about.twitter.com/content/dam/about-twitter/en/brand-toolkit/brand-download-img-1.jpg.twimg.1920.jpg">
</a>