国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 編程 > JavaScript > 正文

JS下拉緩沖菜單示例代碼

2019-11-20 22:20:48
字體:
供稿:網(wǎng)友
復(fù)制代碼 代碼如下:

<!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下拉緩沖菜單_網(wǎng)頁代碼站()</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">草帽海賊團(tuán)船長,特征是頭戴草帽,天性樂觀、熱情、善良、天真、單純。</span>
</li>
<li style="background:url('/images/20130826/psb1.png')">
<a href="#">索隆</a>
<img src="/images/20130826/psb2.jpg" class="map" />
<span class="content">草帽海賊團(tuán)劍士,綠色頭發(fā),左耳戴三只黃色露珠耳環(huán),綠色的肚兜,路癡。</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">精通氣象學(xué)和航海術(shù),擅長偷術(shù)、騙術(shù)、談判及威脅恐嚇,頭腦聰明又機(jī)靈。</span>
</li>
<li style="background:url('/images/20130826/psb1.png')">
<a href="#">山治</a>
<img src="/images/20130826/psb4.jpg" class="map" />
<span class="content">草帽海賊團(tuán)廚師,金發(fā),有著卷曲眉毛,永遠(yuǎn)遮住半邊臉的家伙,海賊中的紳士。</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>
發(fā)表評(píng)論 共有條評(píng)論
用戶名: 密碼:
驗(yàn)證碼: 匿名發(fā)表
主站蜘蛛池模板: 蕲春县| 古交市| 慈溪市| 邯郸市| 靖州| 剑川县| 博兴县| 建瓯市| 遵化市| 九江市| 习水县| 手游| 房山区| 甘谷县| 永寿县| 丹凤县| 辛集市| 华阴市| 玉山县| 邻水| 蕲春县| 思南县| 台南市| 隆安县| 星座| 福安市| 兰州市| 阿克陶县| 措勤县| 偏关县| 朝阳市| 江津市| 宣恩县| 蒙自县| 洪雅县| 波密县| 疏附县| 阜新市| 永修县| 贞丰县| 延长县|