JavaScript、tabel切换完整版—自动切换—鼠标移入停止-移开运行
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Document</title>
<style type="text/css">
*{
margin: 0;
padding: 0;
}
.wrap{
width: 510px;
margin: 0 auto;
overflow: hidden;
position: relative;
}
.caktye{
width: 9999px;
overflow: hidden;
position: relative;
left: 0;
}
.main{
text-align: center;
position: absolute;
bottom: 10px;
left: 35%; }
.main button{
width: 25px;
height: 25px;
text-align: center;
line-height: 25px;
border-radius: 25px;
display: inline-block;
border: none;
}
.active{
background-color: yellow;
}
.caktye a{
float: left;
}
.caktye img {
display: block;
width:510px;
}
#prevBtn{
display: block;
position: absolute;
left: 5px;
bottom: 45%;
width: 15px;
height: 15px;
border-left: 5px solid ;
border-top: 5px solid ;
border-color: rgba(255,255,255,0.5);
-webkit-transform: rotate(-45deg);
transform: rotate(-45deg);
}
#nextBtn{
display: block;
position: absolute;
right: 5px;
bottom: 45%;
width: 15px;
height: 15px;
border-right: 5px solid;
border-top: 5px solid;
-webkit-transform: rotate(45deg);
transform: rotate(45deg);
border-color: rgba(255,255,255,0.5);
} </style>
</head>
<body> <div class="wrap">
<div class="caktye" 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>
</div>
<div class="main">
<button class="active">1</button>
<button>2</button>
<button>3</button>
<button>4</button>
<button>5</button>
</div>
<div>
<a href="###" id="prevBtn"></a>
<a href="###" id="nextBtn"></a> </div>
</div>
<script type="text/javascript">
var innerList = document.getElementById("inner");
var btnList = document.getElementsByTagName("button");
var perWidth = inner.children[0].offsetWidth;
var prevBtn = document.getElementById("prevBtn");
var nextBtn = document.getElementById("nextBtn"); function tab(){
inner.style.left= -perWidth * index + "px"
for(var j=0;j<btnList.length; j++){
btnList[j].className="";
}
btnList[index].className="active";
}
function next() {
index++;
if(index > btnList.length - 1) {
index = 0;
}
tab();
}
function prev() {
index--;
if(index < 0) {
index = btnList.length - 1;
}
tab();
} for(var i=0;i<btnList.length;i++){
btnList[i].index=i;
btnList[i].onclick =function(){
index=this.index;
tab();
} }
var index=0;
function xunhuan(){
index++; if(index>btnList.length -1){
index=0;
}
tab();
} var timer =setInterval(xunhuan,2000); inner.onmouseover =function(){
clearInterval(timer);
}
inner.onmouseout =function(){
timer = setInterval(xunhuan,2000);
} //下一张
nextBtn.onclick = function() {
clearInterval(timer);
next();
timer = setInterval(next,2000);
} //上一张
prevBtn.onclick = function() {
clearInterval(timer);
prev();
timer = setInterval(next,2000);
}
</script>
</body>
</html>
JavaScript、tabel切换完整版—自动切换—鼠标移入停止-移开运行的更多相关文章
- HTML5+JavaScript动画基础 完整版 中文pdf扫描版
<HTML5+JavaScript动画基础>包括了基础知识.基础动画.高级动画.3D动画和其他技术5大部分,分别介绍了动画的基本概念.动画的JavaScript基础.动画中的三角学.渲染技 ...
- ViewPager的基本使用--可左右循环切换也可自动切换
ViewPager也算是Android自带的常用控件之一,但是有可能会无法直接调用,所以只需要将工程目录里/libs/android-support-v4.jar该jarAdd to Build Pa ...
- jquery实现文字自动向上滚动,鼠标放上去停止,移开继续滚动代码...
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8&quo ...
- js写当鼠标悬浮及移开出现背景变化
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/ ...
- javascript实现图片切换、自动走、鼠标移入会停止,移出继续走
要实现以上效果并不难,把功能分开一步一步来实现就变得简单了,录制动态图不流畅,看代码意会吧! <!doctype html> <html lang="en"> ...
- 【温故而知新-Javascript】图片效果(图像震动效果、闪烁效果、自动切换图像)
1.当鼠标指针经过图像时图像震动效果 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" " ...
- bootstrap tab切换如何让鼠标移动自动切换内容
bootstrap集成了很多功能,比如nav-tabs组件,可以将相似的内容集中在一个区块中展示.bootstrap tab切换默认是要点击才会切换的,如何实现鼠标移动就自动切换呢?如下图所示,光标移 ...
- html+css+jQuery+JavaScript实现tab自动切换功能
tab1.html内容 <!DOCTYPE html> <html> <head> <meta charset="UTF-8"> & ...
- javascript实现自动切换焦点功能学习
当用户在表单中填写完当前字段后,能否自动将焦点跳转到下一个字段以方便用户输入? 为了增强易用性,加快数据输入的速度,可以在前一个文本框中的字符达到一定的设置的字符长度后(比如电话号码,身份证号等),用 ...
随机推荐
- soj 2013年 Nanjing Slection
这样加边比STL快! 不明白为什么要+mod #include<iostream> #include<cstdio> #include<queue> #includ ...
- php 类编写
1.没有重载的函数,实现重载函数只能通过func_get_args()这种方式进行转化 2.每个变量只能单独命名为控制权限(private.protected.public) 3.php反射类带参数 ...
- Redis3.0 配置文件说明
背景: 以前有篇文章已经结果过了,现在复习一下,对Redis3.0进行说明: 参数说明: #redis.conf # Redis configuration file example. # ./red ...
- Word 2010 发布博文测试
新建"博客文章" 点击"文件-> 新建 -> 博客文章 -> 创建": 新窗口的编辑区和不同模式的word有所不同,如果你还没有设置博客账号( ...
- K3中间层配置不成功 kdsvrmgr组件不工作 问题 客户端需要检查的设置
苏州K3刘保平电脑安装的K3装有中间层组件,导致中间层死配都配不成功 以后中间层配置不成功的时候除了检查能否访问K3服务器之外,还要检查一下是否安装了中间层http://wenku.baidu.co ...
- jqueyr eq get用法
相信大部份人都会把这2个的用法搞错.仔细查看下API文档就可以知道.eq返回的是一个jquery对象,get返回的是一个html 对象数组.举个例子: <p style="color: ...
- qt creator 源代码中含有中文编译报错
Tools-Options-Text Editor-Behavior-File Encoding-Default encoding:UTF-8 Tools-Options-Text Editor-Be ...
- 不会JavaScript能混前端么?能拿到高薪么?
不会JavaScript能混前端么?能拿到高薪么? 答案是:很难! 为什么这么说呢,理由很简单 1)有很多企业不注重前端开发,当然也就不会给你高薪了,这样的企业以小企业居多. 他们一般对前端开发的认识 ...
- 1 javascript 核心语言笔记
//所有的双斜线之后的内容都属于注释; //变量是表示值的一个符号名字; //变量是通过var 关键字声明的; var x; //声明一个变量 //值可以通过等号赋值给变量 x = 0; //现在的变 ...
- WebView基本使用
WebView mWebView; ProgressBar mProgressBar; mProgressBar = (ProgressBar) findViewById(R.id.news_prog ...