I want to create an animation for a parent element without affecting the child's animation.
My HTML & CSS structure is set up as follows:
.parent{
background-image: url('https://pm1.narvii.com/6195/421ddbf8c9a2fb1715ef833f869164dc1beb8600_hq.jpg');
background-repeat: no-repeat;
background-position: center;
padding: 35px;
margin: 15px 0;
animation-duration: 1s;
animation-fill-mode: both;
animation-timing-function: ease-in-out;
animation-iteration-count: infinite;
}
.parent:hover{
animation-name: bounce;
}
@keyframes bounce {
0%, 100%, 20%, 50%, 80% {
-webkit-transform: translateY(0);
-ms-transform: translateY(0);
transform: translateY(0)
}
40% {
-webkit-transform: translateY(-30px);
-ms-transform: translateY(-30px);
transform: translateY(-30px)
}
60% {
-webkit-transform: translateY(-15px);
-ms-transform: translateY(-15px);
transform: translateY(-15px)
}
}
p{
font-size: 50px;
color: blue;
text-align: center;
}
<div class="parent">
<p>TEST</p>
</div>
Ultimately, I aim to keep the text inside the parent element static. The goal is to animate the image while keeping the text stationary and unaffected by the animation.