【发布时间】:2014-10-07 01:10:33
【问题描述】:
非常感谢基于以下图片的一些帮助:
此外,我正在尝试在div.title-holder 中完成(无限)绿色文本滚动。我的目标是只在 mouseOver 上开始滚动,然后在 div.container 的 mouseOut 上重置。我认为这将是一个简单的任务,只需一点 CSS 和 jQuery,但显然不是这样。这是我的 HTML、CSS 和随附的 JS:
<div class="container">
<div class="title-holder">
<a href="somelink.html">long text that needs to scroll</a>
</div>
<img src="someimage.jpg" />
</div>
相关CSS:
div.title-holder {
width:130px;
height:20px;
overflow:hidden;
white-space:no-wrap;
text-align:center;
}
div.title-holder a {
}
jQuery JS:
$('div.container').hover(
function () {
var scrollingWidth = $(this).find('div.title-holder').find('a').width();
$(this).find('div.title-holder').stop(true, true).animate({scrollLeft: scrollingWidth}, { duration: 5000, easing: 'swing' });
},
function () {
$(this).find('div.title-holder').stop(true, true).animate({scrollLeft: 0}, { duration: 5000, easing: 'swing' });
}
);
现在,这工作正常,除了 2 个问题:
- 它不会无限滚动,并且
- 滚动动作非常非常跳跃/紧张
我真的希望过去有人有类似的要求,并且可以为我阐明这件事。 谢谢!
【问题讨论】:
-
我知道以前有人问过这个问题,但我想要的最终结果不同。