I am having an issue with my CSS marquee, in which images move from right to left. Right now the animation pauses when I hover anywhere inside the "SPAN", empty area or the images. I want the animation to pause on hover, only when hovering on an image; the animation should run normally when hovering on empty areas inside the "SPAN".
Here's my code:
HTML:
<div class="marqueecontainer">
<div class="marquee">
<span>
<img src="images/upcoming01.png" alt="" />
<img src="images/upcoming02.png" alt="" />
</span>
</div>
</div>
CSS:
.marqueecontainer {
overflow: auto;
}
.marquee {
padding: 5px;
margin: 0 auto;
white-space: nowrap;
overflow: hidden;
box-sizing: border-box;
}
.marquee span {
display: inline-block;
padding-left: 50%;
animation: marquee 40s linear infinite;
}
.marquee span:hover {
animation-play-state: paused;
}
@keyframes marquee {
0% {
transform: translate(0, 0);
}
100% {
transform: translate(-100%, 0);
}
}
Try adding classes to each image, like this:
<img class="pauseAnimation" src="images/upcoming01.png" alt="" />
<img class="pauseAnimation" src="images/upcoming02.png" alt="" />
and then to the CSS change it to
.pauseAnimation:hover {
-webkit-animation-play-state: paused; /* Cross Browser Compatability */
-moz-animation-play-state: paused; /* Cross Browser Compatability */
-o-animation-play-state: paused; /* Cross Browser Compatability */
animation-play-state: paused;
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With