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 相关文章推荐
[对联广告] JS脚本类
Aug 27 Javascript
jQuery中的常用事件总结
Dec 27 Javascript
javascript事件冒泡实例分析
May 13 Javascript
AnjularJS中$scope和$rootScope的区别小结
Sep 18 Javascript
AngularJS ng-repeat数组有重复值的解决方法
Oct 23 Javascript
javascript常用经典算法详解
Jan 11 Javascript
canvas绘制环形进度条
Feb 23 Javascript
详解AngularJs HTTP响应拦截器实现登陆、权限校验
Apr 11 Javascript
webpack进阶——缓存与独立打包的用法
Aug 02 Javascript
手写Node静态资源服务器的实现方法
Mar 20 Javascript
基于element-ui组件手动实现单选和上传功能
Dec 06 Javascript
详解阿里Node.js技术文档之process模块学习指南
Jan 04 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
数据库查询记录php 多行多列显示
2009/08/15 PHP
Thinkphp框架 表单自动验证登录注册 ajax自动验证登录注册
2016/12/27 PHP
php nginx 实时输出的简单实现方法
2018/01/21 PHP
php分享朋友圈的实现代码
2019/02/18 PHP
jquery submit ie6下失效的原因分析及解决方法
2013/11/15 Javascript
JavaScript中的异常捕捉介绍
2014/12/31 Javascript
js实现ifram取父窗口URL地址的方法
2015/02/09 Javascript
jQuery 1.9.1源码分析系列(十五)之动画处理
2015/12/03 Javascript
JS中生成随机数的用法及相关函数
2016/01/09 Javascript
javascript中对Date类型的常用操作小结
2016/05/19 Javascript
基于vuejs+webpack的日期选择插件
2020/05/21 Javascript
微信小程序开发探究
2016/12/27 Javascript
javascript实现页面滚屏效果
2017/01/17 Javascript
微信小程序 ecshop地址三级联动实现实例代码
2017/02/28 Javascript
jQuery插件echarts去掉垂直网格线用法示例
2017/03/03 Javascript
Vue 过渡实现轮播图效果
2017/03/27 Javascript
jQuery使用ajax_动力节点Java学院整理
2017/07/05 jQuery
使用 Node.js 实现图片的动态裁切及算法实例代码详解
2018/09/29 Javascript
vue项目前端知识点整理【收藏】
2019/05/13 Javascript
vue 通过base64实现图片下载功能
2020/12/19 Vue.js
Python中一行和多行import模块问题
2018/04/01 Python
对numpy数据写入文件的方法讲解
2018/07/09 Python
pyenv与virtualenv安装实现python多版本多项目管理
2019/08/17 Python
Python-numpy实现灰度图像的分块和合并方式
2020/01/09 Python
Python2和Python3中@abstractmethod使用方法
2020/02/04 Python
python判断元素是否存在的实例方法
2020/09/24 Python
用css3制作纸张效果(外翻卷角)
2013/02/01 HTML / CSS
口腔工艺技术专业毕业生自荐信
2013/09/27 职场文书
企划主管岗位职责
2013/12/12 职场文书
优秀医生事迹材料
2014/02/12 职场文书
收银出纳员岗位职责
2014/02/23 职场文书
2014年外贸业务员工作总结
2014/12/11 职场文书
护理实习生带教计划
2015/01/16 职场文书
行政复议决定书
2015/06/24 职场文书
学校团代会开幕词
2016/03/04 职场文书
电频谱管理的原则是什么
2022/02/18 无线电