我正在使用从右侧到左侧的选取框滚动。下面的代码工作正常。但它滚动不顺畅。 “悬停在我身上停止”内容闪烁或闪烁。我需要下面的选取框有 100% 平滑的滚动。请帮我。没有javascript是否可以?
<marquee behavior='scroll' direction='left' scrollamount='3' onmouseover='this.stop()' onmouseout='this.start()'>Hover on me to stop</marquee>
最佳答案
如果您想尝试使用纯 CSS,那么这是最简单的方法。尽管您需要检查对旧版浏览器的支持并添加供应商前缀。
.marquee-parent {
position: relative;
width: 100%;
overflow: hidden;
height: 30px;
}
.marquee-child {
display: block;
width: 147px;
/* width of your text div */
height: 30px;
/* height of your text div */
position: absolute;
animation: marquee 5s linear infinite; /* change 5s value to your desired speed */
}
.marquee-child:hover {
animation-play-state: paused;
cursor: pointer;
}
@keyframes marquee {
0% {
left: 100%;
}
100% {
left: -147px /* same as your text width */
}
}
<div class="marquee-parent">
<div class="marquee-child">
Hover on me to stop
</div>
</div>
关于html - 选取框滚动不平滑,选取框需要 100% 平滑滚动,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18417056/