JS下拉缓冲菜单示例代码


Posted in Javascript onAugust 30, 2013
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> 
<html xmlns="http://www.w3.org/1999/xhtml"> 
<head> 
<style> 
body,html,div,ul,li,span,img,a{ 
margin:0; 
padding:0; 
} 
a{ 
text-decoration:none; 
color:#000; 
font-weight:bold; 
width:150px; 
display:inline-block; 
text-align:center; 
} 
li{ 
list-style:none; 
} 
img{ 
width:0; 
height:0; 
outline:none; 
} 
#tab{ 
margin:200px 0 0 300px; 
} 
#tab li{ 
float:left; 
width:150px; 
height:50px; 
line-height:50px; 
position:relative; 
margin-right:30px; 
} 
#tab img.map,#tab span.content{ 
position:absolute; 
} 
#tab span.content{ 
background:#333; 
color:#FFF; 
font-size:14px; 
text-align:center; 
height:0; 
} 
#tab img.map{ 
left:50%; 
bottom:0; 
} 
</style> 
<title>JS下拉缓冲菜单_网页代码站()</title> 
</head> <body> 
<div id="tab"> 
<ul> 
<li style="background:url('/images/20130826/psb1.png')"> 
<a href="#">路飞</a> 
<img src="/jscss/demoimg/201210/psb1.jpg" class="map" /> 
<span class="content">草帽海贼团船长,特征是头戴草帽,天性乐观、热情、善良、天真、单纯。</span> 
</li> 
<li style="background:url('/images/20130826/psb1.png')"> 
<a href="#">索隆</a> 
<img src="/images/20130826/psb2.jpg" class="map" /> 
<span class="content">草帽海贼团剑士,绿色头发,左耳戴三只黄色露珠耳环,绿色的肚兜,路痴。</span> 
</li> 
<li style="background:url('/images/20130826/psb1.png')"> 
<a href="#">娜美</a> 
<img src="/jscss/demoimg/201210/psb3.jpg" class="map" /> 
<span class="content">精通气象学和航海术,擅长偷术、骗术、谈判及威胁恐吓,头脑聪明又机灵。</span> 
</li> 
<li style="background:url('/images/20130826/psb1.png')"> 
<a href="#">山治</a> 
<img src="/images/20130826/psb4.jpg" class="map" /> 
<span class="content">草帽海贼团厨师,金发,有着卷曲眉毛,永远遮住半边脸的家伙,海贼中的绅士。</span> 
</li> 
</ul> 
</div> 
<script type="text/javascript"> 
function kzxf_zoom(id) 
{ 
this.initialize.apply(this, arguments) 
} 
kzxf_zoom.prototype = 
{ 
initialize : function() 
{ 
var _this = this; 
this.wrapBox = document.getElementById('tab'); 
this.oLi = this.wrapBox.getElementsByTagName('li'); 
this.aImg = this.wrapBox.getElementsByTagName('img'); 
this.content = this.wrapBox.getElementsByTagName('span'); 
for(var i=0;i<this.oLi.length;i++) 
{ 
(function(i){ 
_this.oLi[i].onmouseover = function() 
{ 
_this.jump(_this.aImg[i], _this.content[i]); 
}; 
_this.oLi[i].onmouseout = function() 
{ 
_this.hidden(_this.aImg[i], _this.content[i]); 
}; 
})(i) 
} 
}, 
jump : function(obj1, obj2) 
{ 
var _this = this; 
_this.animation(obj1, {height:130, width:160, marginLeft:-78, marginTop:-128},function(){ 
_this.animation(obj1, {height:115, width:140, marginLeft:-70, marginTop:-115}, function(){ 
_this.animation(obj1, {height:120, width:150, marginLeft:-75, marginTop:-120}) 
}) 
}); 
_this.animation(obj2, {height:200}); 
}, 
hidden : function(obj1, obj2) 
{ 
var _this = this; 
_this.animation(obj1, {width:0, height:0, marginLeft:0, marginTop:0}); 
_this.animation(obj2, {height:0}); 
}, 
animation : function(obj, oAttr, fnCallBack) 
{ 
var _this = this; 
clearInterval(obj.timer); 
obj.timer = setInterval(function() 
{ 
var bStop = true; 
for(proper in oAttr) 
{ 
var iCur = parseFloat(_this.css(obj, proper)); 
proper == 'opacity' && (iCur = parseInt(iCur.toFixed(2) * 100)); 
var iSpeed = (oAttr[proper] - iCur) / 5; 
iSpeed = iSpeed > 0 ? Math.ceil(iSpeed) : Math.floor(iSpeed); 
if(iCur != oAttr[proper]) 
{ 
bStop = false; 
_this.css(obj, proper, iCur + iSpeed); 
} 
} 
if(bStop) 
{ 
clearInterval(obj.timer); 
fnCallBack && fnCallBack.apply(_this, arguments); 
} 
},20); 
}, 
css : function(obj, attr, value) 
{ 
if(arguments.length == 2) 
{ 
return obj.currentStyle ? obj.currentStyle[attr] : getComputedStyle(obj, null)[attr] 
} 
if(arguments.length == 3) 
{ 
switch(attr) 
{ 
case 'width' : 
case 'height' : 
case 'top' : 
case 'bottom' : 
case 'left' : 
case 'marginLeft': 
case 'marginTop': 
obj.style[attr] = value + 'px'; 
break; 
case 'opacity' : 
obj.style.filter = 'alpha(opacity = '+value+' )'; 
obj.style.opacity = value / 100; 
break; 
default : 
obj.style[attr] = value; 
break; 
} 
} 
} 
}; 
window.onload = function() 
{ 
new kzxf_zoom('tab') 
}; 
</script> 
<br /> 
http://user.qzone.qq.com/1198772766 
</body> 
</html>
Javascript 相关文章推荐
javascripit实现密码强度检测代码分享
Dec 12 Javascript
escape函数解决js中ajax传递中文出现乱码问题
Oct 30 Javascript
javascript中数组的定义及使用实例
Jan 21 Javascript
JavaScript动态创建div等元素实例讲解
Jan 06 Javascript
js内置对象处理_打印学生成绩单的简单实现
Sep 24 Javascript
关于微信上网页图片点击全屏放大效果
Dec 19 Javascript
Bootstrap媒体对象学习使用
Mar 07 Javascript
前端框架学习总结之Angular、React与Vue的比较详解
Mar 14 Javascript
Angular中ng-options下拉数据默认值的设定方法
Jun 21 Javascript
微信小程序基于slider组件动态修改标签透明度的方法示例
Dec 04 Javascript
vue-router动态设置页面title的实例讲解
Aug 30 Javascript
JavaScript类型相关的常用操作总结
Feb 14 Javascript
JQuery 文本框回车跳到下一个文本框示例代码
Aug 30 #Javascript
JQuery设置文本框和密码框得到焦点时的样式
Aug 30 #Javascript
ComboBox 和 DateField 在IE下消失的解决方法
Aug 30 #Javascript
图片Slider 带左右按钮的js示例
Aug 30 #Javascript
javaScript 动态访问JSon元素示例代码
Aug 30 #Javascript
Jquery读取URL参数小例子
Aug 30 #Javascript
返回页面顶部top按钮通过锚点实现(自写)
Aug 30 #Javascript
You might like
解决中英文字符串长度问题函数
2007/01/16 PHP
php生成数组的使用示例 php全组合算法
2014/01/16 PHP
ThinkPHP表单数据智能写入create方法实例分析
2015/09/27 PHP
关于flash遮盖div浮动层的解决方法
2010/07/17 Javascript
JS的replace方法详细介绍
2012/11/09 Javascript
uploadify在Firefox下丢失session问题的解决方法
2013/08/07 Javascript
jQuery代码实现发展历程时间轴特效
2015/07/30 Javascript
js弹出窗口简单实现代码
2017/03/22 Javascript
JavaScript纯色二维码变成彩色二维码
2020/07/23 Javascript
JavaScript数据类型和变量_动力节点Java学院整理
2017/06/26 Javascript
anime.js 实现带有描边动画效果的复选框(推荐)
2017/12/24 Javascript
p5.js入门教程之图片加载
2018/03/20 Javascript
angularJs中跳转到指定的锚点实例($anchorScroll)
2018/08/31 Javascript
trackingjs+websocket+百度人脸识别API实现人脸签到
2018/11/26 Javascript
vue ajax 拦截原理与实现方法示例
2019/11/29 Javascript
[01:47]2018年度DOTA2最具人气解说-完美盛典
2018/12/16 DOTA
Python实现类的创建与使用方法示例
2017/07/25 Python
Python解决N阶台阶走法问题的方法分析
2017/12/28 Python
Python之csv文件从MySQL数据库导入导出的方法
2018/06/21 Python
python实现傅里叶级数展开的实现
2018/07/21 Python
django+echart绘制曲线图的方法示例
2018/11/26 Python
Kali Linux安装ipython2 和 ipython3的方法
2019/07/11 Python
linux环境下Django的安装配置详解
2019/07/22 Python
python Django 反向访问器的外键冲突解决
2020/05/20 Python
ghd法国官方网站:英国最受欢迎的美发工具品牌
2019/04/18 全球购物
印度在线购买电子产品网站:Croma
2020/01/02 全球购物
施工安全协议书
2013/12/11 职场文书
公证书样本
2014/04/10 职场文书
珍惜资源保护环境的建议书
2014/05/14 职场文书
机电一体化应届生求职信
2014/08/09 职场文书
2014幼儿园家长工作总结
2014/11/10 职场文书
安阳殷墟导游词
2015/02/10 职场文书
创业计划书详解
2019/07/19 职场文书
解决Tkinter中button按钮未按却主动执行command函数的问题
2021/05/23 Python
数据库之SQL技巧整理案例
2021/07/07 SQL Server
Python+pyaudio实现音频控制示例详解
2022/07/23 Python