无缝自动滚动

主要是最后一个要跟第一个一样就行了,

复制代码
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><meta http-equiv="Content-Type" content="text/html; charset=utf8">
<title>无标题文档</title>

<style type="text/css">
*
{margin:0;padding:0;}
ul
{list-style:none}
.red
{ background:red;}
.blue
{ background:blue}
.wrap
{width:500px;height:300px;overflow:hidden;position:relative;margin:55px auto}
.inner
{position:absolute;left:0;top:0;}
.wrap li
{float:left;width:500px;height:300px;}
.orange
{ background:orange}
</style>

<script type="text/javascript" src="jquery-1.6.min.js">
</script>

</head>

<body>

<div class="wrap">
<div class="inner">
<ul>
<li class="red"></li>
<li class="blue"></li>
<li class="red"></li>
</ul>
</div>
</div>

<script type="text/javascript">
$(
".inner").css("width",($("li").length*$("li").width())+"px");
var cur =0;
function autoScroll(){

if(cur ==$("li").length-1){
cur
=0;
$(
".inner").css("left","0px")
}
cur
++;
$(
".inner").animate({left:-500*cur},300);


}
setInterval(
function(){
autoScroll()
},
3000)
</script>


</body>
</html>
复制代码



posted @   深蓝色梦想  阅读(244)  评论(0编辑  收藏  举报
编辑推荐:
· Linux系列:如何用 C#调用 C方法造成内存泄露
· AI与.NET技术实操系列(二):开始使用ML.NET
· 记一次.NET内存居高不下排查解决与启示
· 探究高空视频全景AR技术的实现原理
· 理解Rust引用及其生命周期标识(上)
阅读排行:
· 阿里最新开源QwQ-32B,效果媲美deepseek-r1满血版,部署成本又又又降低了!
· 单线程的Redis速度为什么快?
· SQL Server 2025 AI相关能力初探
· 展开说说关于C#中ORM框架的用法!
· AI编程工具终极对决:字节Trae VS Cursor,谁才是开发者新宠?
点击右上角即可分享
微信分享提示