JavaScript-table+大图滚动

<!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;
/*border: 1px solid red;*/
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;
/*overflow: hidden;*/
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;
/*overflow: hidden;*/
border-right: 5px solid;
border-top: 5px solid;
-webkit-transform: rotate(45deg);
transform: rotate(45deg);
border-color: rgba(255,255,255,0.5);
/*background-color: rgba(255,255,255,0.8);*/
} </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>
<a href="###"><img src="img/1.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");
// var imgList = inner.getElementsByTagName("img"); // var perWidth = imgList[0].offsetWidth;
var timer = 0;
var timer1 = 0;
var index =0;
var runFlag = true; //设置一个动画是否走完的标志位 for(var i = 0; i < btnList.length; i++) {
btnList[i].index = i;
btnList[i].onclick = function() {
index = this.index; tab();
}
}
function tab() {
var start = inner.offsetLeft;
var end = - perWidth * index;
var change = end - start;
var t = 0;
var maxT = 30; clearInterval(timer1);
timer1 = setInterval(function() {
t++;
if(t >= maxT) {
clearInterval(timer1);
// alert("停下来了");
runFlag = true;
}
inner.style.left = change/maxT * t + start + "px";
if(index == btnList.length && t >= maxT) {
inner.style.left = 0;
}
},30) // inner.style.left = - perWidth * index + "px";
for(var j = 0; j < btnList.length; j++) {
btnList[j].className = "";
}
if(index >= btnList.length) {
btnList[0].className = "active";
}else {
btnList[index].className = "active";
} }
function xunhuan(){
index++; if(index>btnList.length){
index=1;
}
// inner.style.left = - perWidth * index + "px";
tab();
} var timer =setInterval(xunhuan,5000); inner.onmouseover =function(){
clearInterval(timer);
}
inner.onmouseout =function(){
timer = setInterval(xunhuan,5000);
} function next() {
index++;
if(index > btnList.length) {
index = 1;
}
tab();
}
function prev() {
index--;
if(index < 0 ) {
index = btnList.length - 1;
inner.style.left = - btnList.length * perWidth + "px";
console.log(index);
}
tab();
}
//下一张
nextBtn.onclick = function() {
clearInterval(timer);
if(runFlag) {
next();
}
runFlag = false; }
//上一张
prevBtn.onclick = function() {
clearInterval(timer);
if(runFlag) {
prev();
}
runFlag = false; }
</script>
</body>
</html>
JavaScript-table+大图滚动的更多相关文章
- JavaScript Table行定位效果
作者:cloudgamer 时间: 2009-09-17 文档类型:原创 来自:蓝色理想 第 1 页 JavaScript Table行定位效果 [1] 第 2 页 JavaScript Table行 ...
- jQ版大图滚动
<!DOCTYPE html> <html> <head> <meta charset="utf-8" /> <title&g ...
- 一个jQ版大图滚动
难得周末能休息,也是越发的代码难受,手就想敲点东西,这不闲着无聊敲了一个Jq版的大图滚动,不足之处大家批评指正: 运作环境win7,代码编辑器是:sublime; 我把源码复制了一下, <!do ...
- JavaScript目录菜单滚动反显组件的实现
JavaScript目录菜单滚动反显组件,有以下两个特点 每个导航菜单项(nav)对应页面一个内容区域(content) 滚动页面到特定内容区域(content)时,对应的菜单会自动切换,一般会添加一 ...
- JavaScript实现页面滚动到div区域div以动画方式出现
用JavaScript实现页面滚动效果,以及用wow.js二种方式实现网页滚动效果 要实现效果是页面滚动到一块区域,该区域以动画方式出现. 这个效果需要二点: 一:我们要先写好一个css动画. 二:用 ...
- 使用JavaScript实现新闻滚动效果
最近要实现一个滚动新闻效果,在网上查了一些资料,发现基本的实现方法有两种: 使用Marquee标签.这个标签的使用我已经转载了一篇比较详细的文章,这个标签的优点是便于使用,缺点是人们已经逐渐不适用它了 ...
- Table上下滚动
<table> <tr> <td> <div id="marquees"> <!-- 这些是字幕的内容,你可以任意定义 --& ...
- ul 仿 table 循环滚动
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/ ...
- javascript实现图片滚动
闲来无事捣鼓了一个原来的js图片滚动 首先看看 静态页的结构: <body> <a href="javascript: le()">向左</a> ...
- [转]JavaScript实现 页面滚动图片加载
本文转自:http://www.cnblogs.com/Darren_code/archive/2011/07/21/LoadImage.html 又到了这个月的博客时间了,原计划是打算在这个月做一个 ...
随机推荐
- JSP入门
JSP简介 所谓JSP就是在网页文件中嵌入Java代码或JSP定义的一些标记.JSP是建立在Servlet上的,在执行时JSP容器会先将JSP文件转换成Servlet文件以及class 文件,然后再执 ...
- [Search Engine] 搜索引擎技术之网络爬虫
随着互联网的大力发展,互联网称为信息的主要载体,而如何在互联网中搜集信息是互联网领域面临的一大挑战.网络爬虫技术是什么?其实网络爬虫技术就是指的网络数据的抓取,因为在网络中抓取数据是具有关联性的抓取, ...
- MySQL SQL中的安全问题
一.SQL注入是一个很常见的问题:利用的原理是SQL语句中的 "or"操作符或者"/*"和"#"注释符.前者利用逻辑运算,或者利用MySQL ...
- 解决 iOS 9.1 微信内置浏览器中html audio 不能自动播放的问题
使用微信现在提供过的微信js-sdk 在ready中进行播放便可. 首先引用js : <script src="http://res.wx.qq.com/open/js/jweixin ...
- ToolStripMenuItem
MenuStrip 类 为窗体提供菜单系统. 继承层次结构 System.Object System.MarshalByRefObject System.ComponentModel.Comp ...
- c#.net 生成清晰缩略图
1 public void imgsize() 2 { 3 //本例中假定了两个变量: 4 5 String src = "c:/myImages/a.jpg"; //源图像文件的 ...
- 【krpano】二维码自动生成插件(源码+介绍+预览)
简介 在krpano生成的全景支持HTML5在手机中展示,而在手机中打开全景网址时不方便,需要输入网址. 最近研究了如何让krpano全景根据自己当前的网址,自动生成二维码,并在电脑浏览时,可以展示出 ...
- mysql sql优化实例
mysql sql优化实例 优化前: pt-query-degist分析结果: # Query 3: 0.00 QPS, 0.00x concurrency, ID 0xDC6E62FA021C85B ...
- Spring基础知识
Spring基础知识 利用spring完成松耦合 接口 public interface IOutputGenerator { public void generateOutput(); } 实现类 ...
- [正则表达式]PCRE反向分组引用
在常见的文本匹配场景上,经常会需要用到一些像HTML这样的嵌套标签类型的文本匹配,经过多翻折腾,拼凑出了这样的一条语句 (<([\w]+)>((?1)|[\w\s])*</\2> ...