这是我刚学jquery写的,感觉效果不是很好。

#scrollPics{
height: 330px;
width: 980px;
margin-bottom: 10px;
overflow: hidden;
position:relative;
}
.slider ul{
padding: 0px;
}
.slider ul li{
float: left;
list-style: none;
width: 980px;
}
.num{
position:absolute;
right:5px;
bottom:5px;
}
#scrollPics .num li{
float: left;
color: #FF7300;
text-align: center;
line-height: 16px;
width: 16px;
height: 16px;
cursor: pointer;
overflow: hidden;
margin: 3px 1px;
border: 1px solid #FF7300;
background-color: #fff;
}
#scrollPics .num li.on{
color: #fff;
line-height: 21px;
width: 21px;
height: 21px;
font-size: 16px;
margin: 0 1px;
border: 0;
background-color: #FF7300;
font-weight: bold;
}

<body>
<div id="scrollPics">
<div style="height: 330px;width:5000px " class="slider">
<ul >
<li><img src="data:images/1.jpg"/></li>
<li><img src="data:images/2.jpg"/></li>
<li><img src="data:images/7.jpg"/></li>
<li><img src="data:images/4.jpg"/></li>
<li><img src="data:images/5.jpg"/></li>
</ul>
</div>
<ul class="num" >
<li class="on">1</li>
<li>2</li>
<li>3</li>
<li>4</li>
<li>5</li>
</ul>
</div>
</body>
<script type="text/javascript">
var len = $(".num > li").length;//获取按钮(与图片数量对应)的数量
var index = 0; //图片序号
var adTimer;
$(".num li").mouseover(function() { //当鼠标移到按钮时则显示相对应的图片
index = $(".num li").index(this); //获取鼠标悬浮 li 的index
showImg(index);    
}).eq(0).mouseover();
//滑入停止动画,滑出开始动画.
$('#scrollPics').hover(function() {
clearInterval(adTimer);  //当鼠标移入时停止动画
}, function() {
adTimer = setInterval(function() { //当鼠标移出时动画继续
showImg(index)
index++;   
if (index == len) { //最后一张图片之后,转到第一张
index = 0;
}
}, 2000);
})
function showImg(index) {
var addWidth = $("#scrollPics>.slider>ul>li:first").width(); //获取图片的宽度
$(".slider").animate({
"marginLeft": -addWidth* index + "px" //改变 marginLeft属性的值达到轮播的效果
}, 1000);

//当前图片显示时设置相对应按钮的样式或状态(用类选择器来控制)
$(".num li").removeClass("on")//未显示图片所对应的按钮移除其类选择器的名字
.eq(index).addClass("on"); //当相对应的图片显示时设置当前按钮的类选择器的名字为on
}

</script>
</html>

最新文章

  1. CS0016: 未能写入输出文件“c:\Windows\Microsoft.NET\Framework\v2.0.50727\Temporary ASP.NET Files 解决方案
  2. IOS - NSURLSession
  3. LeetCode 解题报告--202Happy Number
  4. S.O.L.I.D
  5. LPC1114
  6. 配置java软件
  7. icinga 被动模式 nsca 安装
  8. QString::toLocal8Bit得听QTextCodec::codecForLocale的
  9. C语言-指针、数组、结构体、分支、循环混合使用
  10. Problem B: 时间和日期类(III)
  11. rnn_model.fit Incompatible shapes
  12. 前端开发:一个开源、简单易用的jQuery表格插件(DataTables)
  13. 【POJ 1001】Exponentiation (高精度乘法+快速幂)
  14. TypeError: __init__() got an unexpected keyword argument &#39;t_command&#39;
  15. C#完美任意设置webBrowser框架默认的IE内核版本
  16. 同样的so,放到不同的project中,就会报错
  17. Python 时间
  18. mybatis 使用oracle merge into 语句踩坑实录
  19. Asp.net mvc 大文件上传 断点续传 进度条
  20. input 实现onchange效果

热门文章

  1. ASUS S46CB 刷BIOS
  2. win8.1和centos6.5 双系统启动问题
  3. 初始go语言
  4. xfs文件系统磁盘配额
  5. Java Swing 如何实现记事本中“编辑”菜单下的 剪切,复制,粘贴,删除,全选 功能
  6. js构造函数的完美继承(欢迎吐槽)
  7. libev中timer时间事件监控器
  8. js日期操作时间看板
  9. White space is required before the encoding pseudo attribute in the XML declaration.
  10. jQuery复习:第五章