I'm trying to make a animation that makes a div element 10 pixels bigger when hovering and 10 pixels smaller when not hovering. The only problem is that when hovering, it plays the animation, and the element gets 10 pixels bigger as expected, but then the animation ends and the element returns to its original size.
This is the code currently:
.box_1 {
background-color: white;
border-radius: 50px;
display: block;
width: 300px;
height: 400px;
margin-left: 100px;
}
.box_1:hover {
animation-name: bigger;
animation-duration: 2s;
animation-iteration-count: 1;
animation-direction: normal;
}
.box_1:not(hover) {
animation_name: bigger;
animation-duration: 2s;
animation-direction: reverse;
animation-iteration-count: 1;
}
@keyframes bigger {
from {
width: 300px;
height: 400px;
}
to {
width: 310px;
height: 410px;
}
}
I've tried playing the animation then pausing it, but I'd need a wait function. This probably can be easily solved with JavaScript, but I'm trying not to use it (because I'm lazy).