幻灯片之百叶窗

幻灯片之百叶窗,第1张

概述幻灯片百叶窗

下面是内存溢出 jb51.cc 通过网络收集整理的代码片段。

内存溢出小编现在分享给大家,也给大家做个参考。

<!DOCTYPE HTML><HTML><head><Meta http-equiv="Content-type" content="text/HTML; charset=utf-8" /><Title>shutter</Title><style   type="text/CSS" _mce_bogus="1"><!--span{overflow:hidden;Font-size:0;line-height:0}.shutter{position:relative;overflow:hidden;height:300px;wIDth:500px}.shutter li{position:absolute;left:0;top:0;}ul,li{List-style:none;margin:0;padding:0}img{display:block;border:none}.shutter-nav{display:inline-block;margin-right:8px;color:#fff;padding:2px 6px;background:#333;border:1px solID #fff;Font-family:Tahoma;Font-weight:bold;Font-size:12px;cursor:pointer;}.shutter-cur-nav{display:inline-block;margin-right:8px;color:#fff;padding:2px 6px;background:#ff7a00;border:1px solID #fff;Font-family:Tahoma;Font-weight:bold;Font-size:12px;cursor:pointer;}--></style><script type="text/JavaScript"><!--var Hongru={};function H$(ID){return document.getElementByID(ID)}function H$$(c,p){return p.getElementsByTagname(c)}Hongru.shutter = function(){	function init(anchor,options){this.anchor=anchor; this.init(options);}	init.prototype = {		init:function(options){ //options参数:ID(必选):图片列表父标签ID;auto(可选):自动运行时间;index(可选):开始的运行的图片序号			var wp = H$(options.ID),// 获取图片列表父元素			ul = H$$('ul',wp)[0],// 获取			li = this.li = H$$('li',ul);			this.a = options.auto?options.auto:4; //自动运行间隔			this.index = options.position?options.position:0; //开始运行的图片序号(从0开始)			this.l = li.length;			this.cur = 0; //当前显示的图片序号&&z-index变量			this.stN = options.shutterNum?options.shutterNum:5;			this.dir = options.shutterDir?options.shutterDir:'H';			this.W = wp.offsetWIDth;			this.H = wp.offsetHeight;			this.aw = 0;			this.mask = [];			this.nav = [];			ul.style.display = 'none';			var container = this.container = document.createElement('div'),con_a = this._a = document.createElement('a');			con_a.target = '_blank';			container.style.csstext = con_a.style.csstext = 'position:absolute;wIDth:'+this.W+'px;height:'+this.H+'px;left:0;top:0';			container.appendChild(con_a);			for (var x=0; x<this.stN; x++) {				var mask = document.createElement('span');				mask.style.csstext = this.dir == 'H'?'position:absolute;wIDth:'+this.W/this.stN+'px;height:'+this.H+'px;left:'+x*this.W/this.stN+'px;top:0' : 'position:absolute;wIDth:'+this.W+'px;height:'+this.H/this.stN+'px;left:0px;top:'+x*this.H/this.stN+'px';				this.mask.push(mask);				con_a.appendChild(mask);			}			wp.appendChild(container);			this.nav_wp = document.createElement('div'); //先建一个div作为控制器父标签,你也可以用<ul>或<ol>来做,语义可能会更好,这里我就不改了			this.nav_wp.style.csstext = 'position:absolute;right:0;bottom:0;padding:8px 0;'; //为它设置样式			for(var i=0;i<this.l;i++){				/* == 绘制控制器 == */				var nav = document.createElement('a'); //这里我就直接用a标签来做控制器,考虑语义的话你也可以用li				nav.classname = options.navClass?options.navClass:'shutter-nav'; //控制器class,默认为'shutter-nav'				this.nav.push[nav];				nav.INNERHTML = i+1;				nav.onclick = new Function(this.anchor+'.pos('+i+')'); //绑定onclick事件,直接调用之前写好的pos()函数				this.nav_wp.appendChild(nav);			}			wp.appendChild(this.nav_wp);			this.curC = options.curNavClass?options.curNavClass:'shutter-cur-nav';			this.pos(this.index); //变换函数		},auto:function(){			this.li.a = setInterval(new Function(this.anchor+'.move(1)'),this.a*1000); 		},move:function(i){//参数i有两种选择,1和-1,1代表运行到下一张,-1代表运行到上一张			var n = this.cur+i; 			var m = i==1?n==this.l?0:n:n<0?this.l-1:n; //下一张或上一张的序号(注意三元选择符的运用)			this.pos(m); //变换到上一张或下一张		},pos:function(i){			clearInterval(this.li.a);			clearInterval(this.li[i].a);			this.aw = this.dir == 'H'?this.W/this.stN : this.H/this.stN;			var src = H$$('img',this.li[i])[0].src;			var _n = i+1>=this.l?0:i+1;			var src_n = H$$('img',this.li[_n])[0].src;			this.container.style.backgroundImage = 'url('+src_n+')';			for(var n=0;n<this.stN;n++){				this.mask[n].style.csstext = this.dir == 'H'?'position:absolute;wIDth:'+this.W/this.stN+'px;height:'+this.H+'px;left:'+n*this.W/this.stN+'px;top:0' : 'position:absolute;wIDth:'+this.W+'px;height:'+this.H/this.stN+'px;left:0px;top:'+n*this.H/this.stN+'px';				this.mask[n].style.background = this.dir == 'H' ? 'url('+src+') no-repeat -'+n*this.W/this.stN+'px 0' : 'url('+src+') no-repeat 0 -'+n*this.H/this.stN+'px';			}			this.cur = i; //绑定当前显示图片的正确序号			this.li.a = false;			for(var x=0;x<this.l;x++){				H$$('a',this.nav_wp)[x].classname = x==i?this.curC:'shutter-nav'; //绑定当前控制器样式				}			this._a.href = H$$('a',this.li[i])[0].href;			//this.auto(); //自动运行			this.li[i].a = setInterval(new Function(this.anchor+'.anim('+i+')'),4*this.stN);		},anim: function (i) {		var tt = this.dir == 'H' ? parseInt(this.mask[this.stN-1].style.wIDth) : parseInt(this.mask[this.stN-1].style.height);			if(tt<=5){				clearInterval(this.li[i].a);				for(var n=0;n<this.stN;n++){					this.dir == 'H' ? this.mask[n].style.wIDth = 0 : this.mask[n].style.height = 0;				}				if(!this.li.a) {this.auto()}			}else {				for(var n=0;n<this.stN;n++){					this.aw -= 1;					this.dir == 'H' ? this.mask[n].style.wIDth = this.aw + 'px' : this.mask[n].style.height = this.aw + 'px';				}			}		}	}	return {init:init}}();// --></script></head><body><div ID="shutter"   _mce_>	<ul>		<li><a href="http://www.cnblogs.com/hongru/" _mce_href="http://www.cnblogs.com/hongru/" target="_blank"><img src="http://images.cnblogs.com/cnblogs_com/hongru/264552/o_1.jpg" _mce_src="http://images.cnblogs.com/cnblogs_com/hongru/264552/o_1.jpg" /></a></li>		<li><a href="http://www.cnblogs.com/hongru/" _mce_href="http://www.cnblogs.com/hongru/" target="_blank"><img src="http://images.cnblogs.com/cnblogs_com/hongru/264552/o_2.jpg" _mce_src="http://images.cnblogs.com/cnblogs_com/hongru/264552/o_2.jpg" /></a></li>		<li><a href="http://www.cnblogs.com/hongru/" _mce_href="http://www.cnblogs.com/hongru/" target="_blank"><img src="http://images.cnblogs.com/cnblogs_com/hongru/264552/o_3.jpg" _mce_src="http://images.cnblogs.com/cnblogs_com/hongru/264552/o_3.jpg" /></a></li>		<li><a href="http://www.cnblogs.com/hongru/" _mce_href="http://www.cnblogs.com/hongru/" target="_blank"><img src="http://images.cnblogs.com/cnblogs_com/hongru/264552/o_4.jpg" _mce_src="http://images.cnblogs.com/cnblogs_com/hongru/264552/o_4.jpg" /></a></li>		<li><a href="http://www.cnblogs.com/hongru/" _mce_href="http://www.cnblogs.com/hongru/" target="_blank"><img src="http://images.cnblogs.com/cnblogs_com/hongru/264552/o_5.jpg" _mce_src="http://images.cnblogs.com/cnblogs_com/hongru/264552/o_5.jpg" /></a></li>	</ul></div><div ID="shutter2"   _mce_>	<ul>		<li><a href="http://www.cnblogs.com/hongru/" _mce_href="http://www.cnblogs.com/hongru/" target="_blank"><img src="http://images.cnblogs.com/cnblogs_com/hongru/264552/o_1.jpg" _mce_src="http://images.cnblogs.com/cnblogs_com/hongru/264552/o_1.jpg" /></a></li>		<li><a href="http://www.cnblogs.com/hongru/" _mce_href="http://www.cnblogs.com/hongru/" target="_blank"><img src="http://images.cnblogs.com/cnblogs_com/hongru/264552/o_2.jpg" _mce_src="http://images.cnblogs.com/cnblogs_com/hongru/264552/o_2.jpg" /></a></li>		<li><a href="http://www.cnblogs.com/hongru/" _mce_href="http://www.cnblogs.com/hongru/" target="_blank"><img src="http://images.cnblogs.com/cnblogs_com/hongru/264552/o_3.jpg" _mce_src="http://images.cnblogs.com/cnblogs_com/hongru/264552/o_3.jpg" /></a></li>		<li><a href="http://www.cnblogs.com/hongru/" _mce_href="http://www.cnblogs.com/hongru/" target="_blank"><img src="http://images.cnblogs.com/cnblogs_com/hongru/264552/o_4.jpg" _mce_src="http://images.cnblogs.com/cnblogs_com/hongru/264552/o_4.jpg" /></a></li>		<li><a href="http://www.cnblogs.com/hongru/" _mce_href="http://www.cnblogs.com/hongru/" target="_blank"><img src="http://images.cnblogs.com/cnblogs_com/hongru/264552/o_5.jpg" _mce_src="http://images.cnblogs.com/cnblogs_com/hongru/264552/o_5.jpg" /></a></li>	</ul></div><script type="text/JavaScript"><!--var shutterH = new Hongru.shutter.init('shutterH',{	ID:'shutter'});var shutterV = new Hongru.shutter.init('shutterV',{	ID:'shutter2',auto:2,shutterNum:4,shutterDir:'V',position:3});// --></script></body></HTML>

以上是内存溢出(jb51.cc)为你收集整理的全部代码内容,希望文章能够帮你解决所遇到的程序开发问题。

如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。

总结

以上是内存溢出为你收集整理的幻灯片之百叶窗全部内容,希望文章能够帮你解决幻灯片之百叶窗所遇到的程序开发问题。

如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。

欢迎分享,转载请注明来源:内存溢出

原文地址: http://outofmemory.cn/web/1098060.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-05-28
下一篇 2022-05-28

发表评论

登录后才能评论

评论列表(0条)

保存