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

首頁(yè) > 編程 > JavaScript > 正文

JS實(shí)現(xiàn)帶圓弧背景漸變效果的導(dǎo)航菜單代碼

2019-11-20 11:28:27
字體:
來(lái)源:轉(zhuǎn)載
供稿:網(wǎng)友

本文實(shí)例講述了JS實(shí)現(xiàn)帶圓弧背景漸變效果的導(dǎo)航菜單代碼。分享給大家供大家參考。具體如下:

這是一款效果個(gè)性的JS+CSS導(dǎo)航菜單,鼠標(biāo)經(jīng)過(guò)時(shí)出現(xiàn)有趣弧形背景,實(shí)際上,這里用CSS調(diào)用了背景,用JavaScript控制了背景的移動(dòng),用jQuery實(shí)現(xiàn)過(guò)類(lèi)似的功能,整體感覺(jué)很不錯(cuò)。

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

在線(xiàn)演示地址如下:

http://demo.VeVB.COm/js/2015/js-css-cicle-cha-nav-menu-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ǎo)航菜單</title><meta http-equiv="content-type" content="text/html;charset=gb2312"><style type="text/css">*{margin:0px;padding:0px;font-size:12px;}.div_menu{ position:absolute;left:100px;top:100px;}.ul_menu{list-style:none;}.ul_menu li{float:left;margin-left:1px;border:1px solid #33CCCC;display:block;padding:5px 3px;background:url(images/menu_bg.gif) repeat-x 0px -80px;padding:2px 12px;}.ul_menu li a{height:40px;width:auto;color:#ffffff;font-size:20px;font-weight:600;text-decoration:none;}</style><script type="text/javascript">var isIE = (document.all)?true:false;var $ID = function(id){ return "string"==typeof id?document.getElementById(id):id;}var Class = { create:function(){  return function(){   this.initilize.apply(this,arguments);  } }}var Extend = function(destination, source){ for(var property in source){  destination[property] = source[property]; }}var Bind = function(object,fun){ var args = Array.prototype.slice.call(arguments).slice(2); return function(){  return fun.apply(object,args); }}var BindAsEventListener = function(object,fun){ var args = Array.prototype.slice.call(arguments).slice(2); return function(event){  return fun.apply(object,[event||window.event].concat(args)); }}function addEventHandler(oTarget, sEventType, fnHandler) { if (oTarget.addEventListener) {  oTarget.addEventListener(sEventType, fnHandler, false); } else if (oTarget.attachEvent) {  oTarget.attachEvent("on" + sEventType, fnHandler); } else {  oTarget["on" + sEventType] = fnHandler; }};function removeEventHandler(oTarget, sEventType, fnHandler) { if (oTarget.removeEventListener) { oTarget.removeEventListener(sEventType, fnHandler, false); } else if (oTarget.detachEvent) { oTarget.detachEvent("on" + sEventType, fnHandler); } else {  oTarget["on" + sEventType] = null; }};</script><script type="text/javascript">var MyMenu = Class.create();MyMenu.prototype = { initilize:function(ul){  this.lis = ul.getElementsByTagName("li");  for(var i=0;i<this.lis.length;i++){   new BgChange(this.lis[i]);  } }}var BgChange = Class.create();BgChange.prototype = { initilize:function(li){  this.li = li;  this._fnMouseOver = Bind(this,this.MouseOver);  this._fnMouseOut = Bind(this,this.MouseOut);  addEventHandler(this.li,"mouseover",this._fnMouseOver);  addEventHandler(this.li,"mouseout",this._fnMouseOut);  this.timer = null;  this.i = -80; }, MouseOver:function(){  this.Stop();  this.i+=2;  if(this.i>=0){   window.clearTimeout(this.timer);   this.i = 0;  }else{   this.ShowBg();   this.timer = window.setTimeout(this._fnMouseOver,10);  } }, MouseOut:function(){  this.Stop();  this.i-=2;  if(this.i<=-80){   window.clearTimeout(this.timer);   this.i = -80;  }else{   this.ShowBg();   this.timer = window.setTimeout(this._fnMouseOut,10);  } }, ShowBg:function(){  this.li.style.backgroundPosition = "0px " + this.i + "px"; }, Stop:function(){  if(this.timer){   window.clearTimeout(this.timer);  } }}onload = function(){ new MyMenu($ID("ul_menu"));}</script></head><body><div class="div_menu"> <ul class="ul_menu" id="ul_menu"> <li><a href="#">歡迎光臨</a></li> <li><a href="#">最新更新</a></li> <li><a href="#">下載排行</a></li> <li><a href="#">網(wǎng)頁(yè)特效</a></li> <li><a href="#">廣告聯(lián)系</a></li> </ul></div></body></html>

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

發(fā)表評(píng)論 共有條評(píng)論
用戶(hù)名: 密碼:
驗(yàn)證碼: 匿名發(fā)表
主站蜘蛛池模板: 玛纳斯县| 响水县| 友谊县| 方正县| 平谷区| 屏边| 张掖市| 西乡县| 浙江省| 多伦县| 吉安县| 罗定市| 景洪市| 吉首市| 大庆市| 永安市| 禄劝| 息烽县| 寿宁县| 土默特右旗| 饶平县| 永嘉县| 石门县| 苍梧县| 辰溪县| 新泰市| 三台县| 沂南县| 天水市| 岳阳市| 广宗县| 高州市| 赣榆县| 宜宾市| 新民市| 新建县| 文水县| 贵溪市| 莆田市| 肇东市| 沂水县|