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

首頁 > 編程 > JavaScript > 正文

jquery實(shí)現(xiàn)動(dòng)畫菜單的左右滾動(dòng)、漸變及圖形背景滾動(dòng)等效果

2019-11-20 11:43:27
字體:
供稿:網(wǎng)友

本文實(shí)例講述了jquery實(shí)現(xiàn)動(dòng)畫菜單的左右滾動(dòng)、漸變及圖形背景滾動(dòng)等效果。分享給大家供大家參考。具體如下:

這里演示基于jquery實(shí)現(xiàn)的動(dòng)畫菜單,內(nèi)含四種效果的網(wǎng)站菜單,第一種是不帶效果的傳統(tǒng)導(dǎo)航菜單,第二種是帶有圖形滾動(dòng)背景的菜單,第三種是由右向左背景滾動(dòng)的菜單,第四種則是背景色漸變的網(wǎng)站菜單,每一種都很精彩,喜歡Js菜單的可模仿借鑒一下。

運(yùn)行效果截圖如下:

在線演示地址如下:

http://demo.VeVB.COm/js/2015/jquery-flash-style-cha-menu-codes/

具體代碼如下:

<!DOCTYPE html><head><meta http-equiv="Content-Type" content="text/html; charset=gbk" /><title>jQuery動(dòng)態(tài)背景導(dǎo)航菜單</title><style type="text/css">h2{clear: both;padding-top: 20px;}ul{list-style: none;margin: 0;padding: 0;}li{float: left;width: 100px;margin: 0;padding: 0;text-align: center;}li a{display: block;padding: 5px 10px;height: 100%;color: #FFF;text-decoration: none;border-right: 1px solid #FFF;}li a{background: url(images/bg2.jpg) repeat 0 0;}li a: hover, li a: focus, li a: active{background-position: -150px 0;}#a a{background: url(images/bg.jpg) repeat -20px 35px;}#b a{background: url(images/bg2.jpg) repeat 0 0;}#c a{background: url(images/bg3.jpg) repeat 0 0;}#d a{background: url(images/bg4.jpg) repeat 0 0;}</style><script type="text/javascript" src="jquery-1.6.2.min.js"></script><script type="text/javascript">(function($) { $.extend($.fx.step,{  backgroundPosition: function(fx) {  if (fx.state === 0 && typeof fx.end == 'string') {  var start = $.curCSS(fx.elem,'backgroundPosition');  start = toArray(start);  fx.start = [start[0],start[2]];  var end = toArray(fx.end);  fx.end = [end[0],end[2]];  fx.unit = [end[1],end[3]];   }  var nowPosX = [];  nowPosX[0] = ((fx.end[0] - fx.start[0]) * fx.pos) + fx.start[0] + fx.unit[0];  nowPosX[1] = ((fx.end[1] - fx.start[1]) * fx.pos) + fx.start[1] + fx.unit[1];  fx.elem.style.backgroundPosition = nowPosX[0]+' '+nowPosX[1];  function toArray(strg){  strg = strg.replace(/left|top/g,'0px');  strg = strg.replace(/right|bottom/g,'100%');  strg = strg.replace(/([0-9/.]+)(/s|/)|$)/g,"$1px$2");  var res = strg.match(/(-?[0-9/.]+)(px|/%|em|pt)/s(-?[0-9/.]+)(px|/%|em|pt)/);  return [parseFloat(res[1],10),res[2],parseFloat(res[3],10),res[4]];  } } });})(jQuery);</script><script type="text/javascript">$(function(){ $('#a a')  .css( {backgroundPosition: "-20px 35px"} )  .mouseover(function(){   $(this).stop().animate({backgroundPosition:"(-20px 94px)"}, {duration:500})  })  .mouseout(function(){   $(this).stop().animate({backgroundPosition:"(40px 35px)"}, {duration:200, complete:function(){    $(this).css({backgroundPosition: "-20px 35px"})   }})  }) $('#b a')  .css( {backgroundPosition: "0 0"} )  .mouseover(function(){   $(this).stop().animate({backgroundPosition:"(-150px 0)"}, {duration:500})  })  .mouseout(function(){   $(this).stop().animate({backgroundPosition:"(-300px 0)"}, {duration:200, complete:function(){    $(this).css({backgroundPosition: "0 0"})   }})  }) $('#c a')  .css( {backgroundPosition: "0 0"} )  .mouseover(function(){   $(this).stop().animate({backgroundPosition:"(0 -250px)"}, {duration:500})  })  .mouseout(function(){   $(this).stop().animate({backgroundPosition:"(0 0)"}, {duration:500})  }) $('#d a')  .css( {backgroundPosition: "0 0"} )  .mouseover(function(){   $(this).stop().animate({backgroundPosition:"(0 -250px)"}, {duration:500})  })  .mouseout(function(){   $(this).stop().animate({backgroundPosition:"(0 0)"}, {duration:500})  })});</script><meta http-equiv="Content-Type" content="text/html;charset=gbk"></head><body><h1>jQuery Background Position</h1><h2>Example 0: No Script</h2> <ul id="noscript">  <li><a href="#">Home</a></li>  <li><a href="#">About</a></li>  <li><a href="#">Contact</a></li> </ul><h2>Example A: Top down</h2> <ul id="a">  <li><a href="#">Home</a></li>  <li><a href="#">About</a></li>  <li><a href="#">Contact</a></li> </ul><h2>Example B: Right left</h2> <ul id="b">  <li><a href="#">Home</a></li>  <li><a href="#">About</a></li>  <li><a href="#">Contact</a></li> </ul><h2>Example C: Fade 1-colour</h2> <ul id="c">  <li><a href="#">Home</a></li>  <li><a href="#">About</a></li>  <li><a href="#">Contact</a></li> </ul><h2>Example D: Fade 2-colour</h2> <ul id="d">  <li><a href="#">Home</a></li>  <li><a href="#">About</a></li>  <li><a href="#">Contact</a></li> </ul></body></html>

希望本文所述對(duì)大家的jquery程序設(shè)計(jì)有所幫助。

發(fā)表評(píng)論 共有條評(píng)論
用戶名: 密碼:
驗(yàn)證碼: 匿名發(fā)表
主站蜘蛛池模板: 保靖县| 凉山| 开江县| 德令哈市| 海宁市| 临漳县| 秀山| 九台市| 堆龙德庆县| 自治县| 徐闻县| 昭通市| 苍南县| 伊金霍洛旗| 常德市| 教育| 麻栗坡县| 昭苏县| 双牌县| 曲阜市| 静安区| 灵武市| 诏安县| 革吉县| 曲阳县| 从化市| 巴中市| 洪雅县| 白水县| 北海市| 理塘县| 汤阴县| 禹州市| 柘荣县| 新巴尔虎右旗| 漳浦县| 瑞金市| 白玉县| 新宁县| 华宁县| 黔西|