Take a look at the code snippet below. As you hover over an item, you'll notice the background color changes, but the transform: translateY(-5px)
property is not being applied. The transform effect on hover only works when the .list-item animation is not set.
Is there a way to make the translateY(-5px)
transformation work while keeping the current animation intact?
.list {
display: flex;
flex-direction: column;
align-items: center;
margin: 24px 0;
}
.list-item {
cursor: pointer;
margin-bottom: 14px;
padding: 12px 16px;
border-radius: 50px;
background: #EFEFEF;
animation-name: popin;
animation-fill-mode: both;
animation-duration: .6s;
animation-iteration-count: 1;
animation-timing-function: ease;
animation-delay: 0.1s;
}
.list-item:hover {
background-color: yellow;
transform: translateY(-5px);
}
@keyframes popin {
0%{
transform:scale(0);
}
50%{
transform:scale(1.1);
}
100%{
transform:scale(1);
}
}
<div class="list">
<div class="list-item">item</div>
<div class="list-item">item</div>
<div class="list-item">item</div>
<div class="list-item">item</div>
<div class="list-item">item</div>
<div class="list-item">item</div>
</div>
UPDATE:
Additionally, I am looking for a transition effect to be applied once the translation has taken place.