要实现以上效果并不难,把功能分开一步一步来实现就变得简单了,录制动态图不流畅,看代码意会吧!

<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Document</title>
<style>
* {margin:0; padding: 0}
button {
width: 50px;
}
p {
text-align: center;
}
.active {
background-color: yellow;
}
#wrap {
width:210px;
overflow: hidden;
margin:0 auto;
}
#inner {
width:9999px;
overflow: hidden;
position: relative;
left:0;
transition: left 0.6s;
}
#inner a {
float: left;
}
#inner img {
display: block;
width:210px;
}
</style> </head>
<body> <div id="wrap">
<div id="inner">
<a href="###"><img src="img/1.jpg"></a>
<a href="###"><img src="img/2.jpg"></a>
<a href="###"><img src="img/3.jpg"></a>
<a href="###"><img src="img/4.jpg"></a>
<a href="###"><img src="img/5.jpg"></a>
<a href="###"><img src="img/6.jpg"></a>
<a href="###"><img src="img/7.jpg"></a>
<a href="###"><img src="img/8.jpg"></a>
<a href="###"><img src="img/9.jpg"></a>
<a href="###"><img src="img/10.jpg"></a>
<a href="###"><img src="img/11.jpg"></a>
<a href="###"><img src="img/12.jpg"></a>
<a href="###"><img src="img/13.jpg"></a>
<a href="###"><img src="img/14.jpg"></a>
</div>
</div>
<p>
<button class="active">1</button>
<button>2</button>
<button>3</button>
<button>4</button>
<button>5</button>
<button>6</button>
<button>7</button>
<button>8</button>
<button>9</button>
<button>10</button>
<button>11</button>
<button>12</button>
<button>13</button>
<button>14</button>
</p>
<script type="text/javascript">
//1.找节点
var buttonList = document.getElementsByTagName("button");
var inner = document.getElementById("inner");
var perWidth = inner.children[0].offsetWidth; function tab() {
inner.style.left = - perWidth * index + "px";
for(var j = 0; j < buttonList.length; j++) {
buttonList[j].className = "";
}
buttonList[index].className = "active";
}
for(var i = 0; i < buttonList.length; i++) {
buttonList[i].index = i;
buttonList[i].onclick = function() {
index = this.index;
tab();
}
}
var index = 0;
function next() {
index ++;
if(index > buttonList.length - 1) {
index = 0;
}
tab();
}
var timer = setInterval(next,1000); inner.onmouseover = function() {
// alert("鼠标移入");
clearInterval(timer);
}
inner.onmouseout = function() {
timer = setInterval(next,1000);
}
</script>
</body>
</html>

以后还会继续添加些效果补充完整的....

最新文章

  1. TypeScript 素描-变量声明
  2. 一个java源文件中为什么只能有一个public类。
  3. java和c#使用hessian通信
  4. 正则表达式入门(六)匹配unicode和其他字符
  5. Android ORM应用开发框架KJFrameForAndroid使用详解
  6. C# 表达式学习积累
  7. Photoshop 使用可选颜色
  8. Codeforces Round #227 (Div. 2) E. George and Cards 线段树+set
  9. 【转】 Spinner的常用技巧
  10. C#图像处理(1):在图片上加文字和改变文字的方向
  11. uvc摄像头代码解析5
  12. ecshop中getAll ,getOne ,getRow的区别
  13. MEF初体验之二:定义组合部件和契约
  14. WebApi 跨域问题解决方案:CORS
  15. 201621123040《Java程序设计》第5周学习总结
  16. spring boot Websocket(使用笔记)
  17. [Swift]LeetCode186. 翻转字符串中的单词 II $ Reverse Words in a String II
  18. Swagger Annotation 详解(建议收藏)
  19. CentOS_mini下安装docker 之 yum mount
  20. python 对时间操作

热门文章

  1. D1.1.利用npm(webpack)构建基本reactJS项目
  2. 黑马程序员——OC基础 三种特性之封装
  3. 使用strace 工具跟踪系统调用和信号
  4. 基本矩阵运算的Java实现
  5. css渐变色DIV
  6. StoryBoard解惑
  7. Configure the max limit for concurrent TCP connections(转)
  8. IOS中的编码规范
  9. jbox用法
  10. :before :after