JavaScript+CSS實(shí)現(xiàn)仿Mootools豎排彈性動(dòng)畫菜單效果
本文實(shí)例講述了JavaScript+CSS實(shí)現(xiàn)仿Mootools豎排彈性動(dòng)畫菜單效果。分享給大家供大家參考。具體如下:
這里演示JavaScript+CSS仿Mootools豎排黑色動(dòng)畫菜單,并非使用了Mootools,但效果卻和使用了Mootools差不多,動(dòng)畫效果平滑,操作舒服,給菜單增色不少。
運(yùn)行效果截圖如下:

在線演示地址如下:
http://demo.jb51.net/js/2015/js-css-mootools-style-demo/
具體代碼如下:
<!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>
<title>豎排黑色動(dòng)畫菜單</title>
<style type="text/css">
#menu {
height: auto;
width: 350px;
float: left;
}
body {
overflow: auto;
background: #333;
color: #FFF;
font: 12px Arial, Helvetica, sans-serif;
}
#menu li {
display: block;
list-style-type: none;
}
#menu a {
font-size: 11px;
color: #FFF;
padding-right: 10px;
padding-left: 10px;
line-height: 30px;
text-decoration: none;
background: #000 url(images/bg.jpg) no-repeat left;
height: 30px;
width: 180px;
display: block;
outline:0;
margin-bottom: 5px;
}
#menu a:hover {
color: #CCFF00;
background: #000 url(images/bg1.jpg) no-repeat left;
}
</style>
</head>
<body>
<div id="menu">
<ul>
<li><a href="#" title="" class="toggler">JQuery插件</a></li>
<li><a href="#" class="toggler">Ext 皮膚</a></li>
<li><a href="#" class="toggler">CSS特效</a></li>
<li><a href="#">Ajax技巧集</a></li>
</ul>
</div>
<script type="text/javascript">
var $ = function(_sId){return typeof _sId == 'string' ? document.getElementById(_sId) : _sId;}
var Each=function (a,fn){for(var i=0;i<a.length;i++)fn.call(a[i],i,a)};
var Tweener = {
easeNone: function(t, b, c, d) {
return c*t/d + b;
},
easeOutBounce: function(t, b, c, d) {
if((t/=d) <(1/2.75)) {
return c*(7.5625*t*t) + b;
} else if(t <(2/2.75)) {
return c*(7.5625*(t-=(1.5/2.75))*t + .75) + b;
} else if(t <(2.5/2.75)) {
return c*(7.5625*(t-=(2.25/2.75))*t + .9375) + b;
} else {
return c*(7.5625*(t-=(2.625/2.75))*t + .984375) + b;
}
}
};
Each($('menu').getElementsByTagName('a'), function(){
this.onmouseover = function(){
var b = parseInt(this.style.marginLeft);
b = isNaN(b) ? 0 : b;
var t=0,c=30-b,d =10,ttl=10;
var me = this;
clearInterval(me.only);
me.only=setInterval(function (){
me.style.marginLeft = Tweener.easeNone(t,b,c,d)+'px';
if(t<d) t++;
else{
clearInterval(me.only);
}
},ttl)
}
this.onmouseout = function(){
var b = parseInt(this.style.marginLeft);
b = isNaN(b) ? 0 : b;
var t=0,c=0-b,d =50,ttl=10;
var me = this;
clearInterval(me.only);
me.only=setInterval(function (){
me.style.marginLeft = Tweener.easeOutBounce(t,b,c,d)+'px';
if(t<d) t++;
else{
clearInterval(me.only);
}
},ttl)
}
}
);
</script>
</body>
</html>
希望本文所述對(duì)大家的JavaScript程序設(shè)計(jì)有所幫助。
相關(guān)文章
重置Redux的狀態(tài)數(shù)據(jù)的方法實(shí)現(xiàn)
這篇文章主要介紹了重置Redux的狀態(tài)數(shù)據(jù)的方法實(shí)現(xiàn),文中通過示例代碼介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友們下面隨著小編來一起學(xué)習(xí)學(xué)習(xí)吧2019-11-11
js canvas實(shí)現(xiàn)隨機(jī)粒子特效
這篇文章主要為大家詳細(xì)介紹了js canvas隨機(jī)粒子特效,文中示例代碼介紹的非常詳細(xì),具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下2021-04-04
IE6/7/8中Option元素未設(shè)value時(shí)Select將獲取空字符串
可以看到當(dāng)忘記寫option的value時(shí)這些現(xiàn)代瀏覽器都會(huì)盡量返回正確的(客戶端程序員想要的)結(jié)果value,其容錯(cuò)性比IE6/7/8做的更好。2011-04-04
JavaScript下一版本標(biāo)準(zhǔn)ES6的Set集合使用詳解
ES6:全稱ECMAScript 6.0,是JavaScript語言的國(guó)際標(biāo)準(zhǔn),JavaScript是ECMAScript的實(shí)現(xiàn)。今天我們就來學(xué)習(xí)一下ES6的Set集合的使用2023-02-02

