设为首页 加入收藏

TOP

[js高手之路]封装运动框架实战左右与上下滑动的焦点轮播图(四)
2017-10-16 18:19:15 】 浏览:7605
Tags:高手 封装 运动 框架 实战 左右 上下 滑动 焦点
h
: 4000px; 25 } 26 #img-container img { 27 display: block; 28 float: left; 29 } 30 #slide-nums { 31 position: absolute; 32 right:10px; 33 bottom:10px; 34 } 35 #slide-nums li { 36 float: left; 37 margin:0px 10px; 38 background: white; 39 width: 20px; 40 height: 20px; 41 text-align: center; 42 line-height: 20px; 43 border-radius:10px; 44 text-indent:-999px; 45 opacity:0.6; 46 filter:alpha(opacity:60); 47 cursor:pointer; 48 } 49 #slide-nums li.active { 50 background: red; 51 } View Code

js调用文件:

 1 window.onload = function () {
 2     function Slide() {
 3         this.oImgContainer = document.getElementById("img-container");
 4         this.aLi = document.getElementsByTagName("li");
 5         this.index = 0;
 6     }
 7 
 8     Slide.prototype.bind = function () {
 9         var that = this;
10         for (var i = 0; i < this.aLi.length; i++) {
11             this.aLi[i].index = i;
12             this.aLi[i].onmouseover = function () {
13                 that.moveLeft( this.index );
14             }
15         }
16     }
17 
18     Slide.prototype.moveLeft = function (i) {
19         this.index = i;
20         for( var j = 0; j < this.aLi.length; j++ ){
21            this.aLi[j].className = '';
22         }
23         this.aLi[this.index].className = 'active';
24         animate( this.oImgContainer, {
25             "left" : -this.index * 800
26         });
27     }
28     
29     var oSlide = new Slide();
30     oSlide.bind();
31 
32 }
View Code

 

首页 上一页 1 2 3 4 下一页 尾页 4/4/4
】【打印繁体】【投稿】【收藏】 【推荐】【举报】【评论】 【关闭】 【返回顶部
上一篇WEB前端JS与UI框架 下一篇【css】css2实现两列三列布局的方..

最新文章

热门文章

Hot 文章

Python

C 语言

C++基础

大数据基础

linux编程基础

C/C++面试题目