gpt4 book ai didi

html - 暂停图像悬停而不是空白区域 - HTML,CSS

转载 作者:可可西里 更新时间:2023-11-01 13:46:31 26 4
gpt4 key购买 nike

我的 CSS 选框出现问题,图像从右移到左。现在,当我将鼠标悬停在“SPAN”、空白区域或图像内的任何位置时,动画会暂停。我希望动画在悬停时暂停,仅当悬停在图像上时;将鼠标悬停在“SPAN”内的空白区域时,动画应该可以正常运行。

这是我的代码:

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);
}
}

最佳答案

尝试为每个图像添加类,如下所示:

<img class="pauseAnimation" src="images/upcoming01.png" alt="" />
<img class="pauseAnimation" src="images/upcoming02.png" alt="" />

然后将CSS更改为

.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;
}

关于html - 暂停图像悬停而不是空白区域 - HTML,CSS,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41739155/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com