在 jQuery 中连续滚动包含图像的水平滚动条?

发布于 2024-08-02 08:49:48 字数 221 浏览 9 评论 0原文

我想做这样的事情:http://javascript.about.com/library/blcmarquee1。 htm

然而,我引用的脚本似乎有点滞后(过时?),所以我想知道是否有人知道更好的解决方案。 (欢迎使用 jQuery 解决方案。)

I would like to do something like this: http://javascript.about.com/library/blcmarquee1.htm

The script I referenced however seems to be a bit laggy (outdated?), so I was wondering if anyone knew of a better solution. (jQuery solutions welcome.)

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

脱离于你 2024-08-09 08:49:48

刚刚发现这个 - jQuery 驱动的,并且有图像。我打算将它用于当前的项目。

http://logicbox.net/jquery/simplyscroll/

更新:我现在已在生产中使用它代码。该插件能够非常流畅地循环 70+ 150×65px 图像 - 我尝试过的其他一些与此类似的插件都失败了。

注意,它在 IE 6 / 7 中因 z-index 问题而造成严重破坏,并且没有显示出来等。 - 但这也可能部分归因于我的 CSS。对于在 IE 中根本无法显示该问题的任何人,请查看标准 IE z-index 修复:http://www.google.com/search?q=ie+z+index+issues

最新更新:
实现此类插件时还需要考虑以下事项:

  • 要滚动的项目数量和内容类型。我发现当你要滚动的图像超过 15 个时,这个数字就会开始出现故障。
  • 我发现许多与旧版本的 jquery 相关的插件
  • 如果滚动图像的大小都相同,我尝试过的许多插件仅在所有图像大小相同时才起作用,但没有做到这一点教程里说的很清楚。我相信然后插件运行然后设置一串 li 标签,这些标签都是 x 宽,然后计算它们全部链接在一起的总距离以管理滚动。
  • 效果 - 有些会连续滚动,有些会移动一个图像暂停一秒钟,然后移动另一个图像

我现在也发现这两个滚动器插件也非常好。

http://caroufredsel.frebsite.nl/

http://sorgalla.com/jcarousel/

Just found this — jQuery-driven, and has images. I’m intending to use it for a current project.

http://logicbox.net/jquery/simplyscroll/

UPDATE: I have now used this in production code. The plugin is capable of looping 70+ 150×65px images pretty smoothly - which a number of another plugin I tried similar to this were failing on.

NOTE it reeked havoc with z-index issues in IE 6 / 7 and was not showing up etc. - But this might also have been partly due to my CSS. To anyone having trouble with it not showing up at all in IE check out the standard IE z-index fixes: http://www.google.com/search?q=ie+z+index+issues

LATEST UPDATE:
Addition things to consider when implementing plug-ins like these:

  • The number of items and type of content to scroll. I found a number that would start to glitch as soon as you had more than say 15 images to scroll.
  • I found a number of these plugins that were tied to old versions of jquery
  • If scrolling images ARE THEY ALL THE SAME SIZE again a number of the plug-ins I experimented with only worked if all the images were the same size but did not make this clear in the tutorials. I believe then the plugins run then set a string of li tags that are all x wide then calculate the total distance of them all chained together to manage the scrolling.
  • Effects - some would continuously scroll others would move one image pause for a second then move another image

I have now also found these two scroller plugins to be very good as well.

http://caroufredsel.frebsite.nl/

http://sorgalla.com/jcarousel/

来世叙缘 2024-08-09 08:49:48

只是一个想法。你能做这样的事情吗?

<style type="text/css">

.imgwindow{
width:500px; //or whatever
height:65px; //or whatever
position:relative;
overflow:hidden;
}

.imgholder{
min-width:2000px;
height:65px;
position:absolute;
left:-200px;
}

.inline-image{
display:inline-block;
}

</style>

<script type="text/javascript">

var img;

function imgScroll(){
 img = $(".inline-image").first();
 img.animate({width:0},2500,'linear',function(){
   img.remove();
   $(".imgholder").append(img);
   imgScroll();
 });

}

$(document).ready(function(){

imgScroll();  

});

</script>

和html

<div class="imgwindow">
  <div class="imgholder">
   <img class="inline-image" src="image1" /><img class="inline-image" src="image2" />...
  </div>
</div>

Just a thought. Could you do something like this.

<style type="text/css">

.imgwindow{
width:500px; //or whatever
height:65px; //or whatever
position:relative;
overflow:hidden;
}

.imgholder{
min-width:2000px;
height:65px;
position:absolute;
left:-200px;
}

.inline-image{
display:inline-block;
}

</style>

<script type="text/javascript">

var img;

function imgScroll(){
 img = $(".inline-image").first();
 img.animate({width:0},2500,'linear',function(){
   img.remove();
   $(".imgholder").append(img);
   imgScroll();
 });

}

$(document).ready(function(){

imgScroll();  

});

</script>

and the html

<div class="imgwindow">
  <div class="imgholder">
   <img class="inline-image" src="image1" /><img class="inline-image" src="image2" />...
  </div>
</div>
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文