jquery实现网站导航动画滑动效果

<! DOCTYPE   html   PUBLIC   "-//W3C//DTD HTML 4.01 Transitional//EN"   "http://www.w3.org/TR/html4/loose.dtd"   >
< html >
< head >
< meta   http-equiv = "Content-Type"   content = "text/html; charset=UTF-8" >
< title >   Insert title here </ title   >
< script   type = "text/javascript"   src = "http://www.haodou.com/public/js/jquery-1.5.1.min.js"   ></ script >
< style   type = "text/css"   >
         ul,   li   {   margin   :   0 ;   padding :   0 ;}
         .clear {   clear   :   both ;}
         #nav_ul {   width   :   800px ;   height : 40px ;   background : url(http://www.haodou.com/public/images/public/group/5.jpg) left top no-repeat ; }
         #nav_ul li   {   width :   100px   ;   height   :   40px ;   display :   block ;   float   :   left ;}
         #nav_ul .active {   width :   100px   ;   height   :   40px ;   background : url(http://www.haodou.com/public/images/public/group/5.jpg) left top no-repeat ;}
</ style >
</ head >
< body >

< div >
         < ul   id =   "nav_ul" >
               < li ><   a   href   = "http://www.temi.com.cn" >   特米首页 </ a   ></ li >
               < li ><   a   href   = "http://shop.temi.com.cn" >   商城导航 </ a   ></ li >
               < li ><   a   href   = "http://brand.temi.com.cn" >   品牌导航 </ a   ></ li >
               < li ><   a   target   = "_blank"   href = "http://tuan.temi.com.cn"   > 团购导航 </   a ></ li   >
               < li ><   a   href   = "http://dianpu.temi.com.cn" >   淘宝店铺 </ a   ></ li >
               < li ><   a   href   = "http://taobao.temi.com.cn" >   淘宝商品 </ a   ></ li >
               < li ><   a   href   = "http://re.temi.com.cn" >   淘宝热卖 </ a   ></ li >
               < li ><   a   href   = "#" >   导购资讯 </ a   ></ li >
         </ ul >
         < div   class = "clear"   ></ div >
</ div >


< script   type = "text/javascript"   >
      $(document).ready(   function   (){
               var   arr_sub_domain =   new   Array( "www" ,   "shop" ,   "brand"   ,   "tuan" ,   "dianpu"   ,   "taobao"   ,   "re"   ,   "info"   )
               var   str_sub_domain = location.href.split( "//"   )[1].split( "." )[0];
            
               var   lock =   false ;
               var   nav_ul = $( "#nav_ul"   );
            nav_ul.children().each(   function   (i){
                     var   _this = $( this );
                  
                     //绑定mouseover事件的动态效果
                  _this.bind(   "mouseover" ,   function   (){
                        nav_ul.animate(
                              {backgroundPosition: i*100},
                              {duration:1000, queue:   false }
                        );
                  });
                  
                     //导航当前页设置样式
                  if   (! lock  &&   arr_sub_domain[i] == str_sub_domain) {
                        _this.addClass(   "nav_active" );
                        _this.css(   "background-position" , i*100);
                        flag =   true ;
                  }
            });
      });
</ script >
</ body >
</ html >

123宝贝网(www.123baby.net)
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值