用javascript来实现仿gogle动画导航
作者:buliuming 来源:蓝色理想 发布时间:2007-11-30 14:15:00
谁在用这些导航
google是个大公司,全世界都有google的脚印,韩国的google动画效果非常不错,蓝色理想论坛里已经有人挖过来了,可惜js写的太多了,那自己写一个吧?好,就这么干!
原理
小时候,总喜欢看动画片吧,动画片是怎样实现的呢?记得妈妈说是一张画一张画切换过去(啊?那一部葫芦兄弟要画多少副画啊? -_-! ),其实我们现在做的也是这样,用一个图片,这个图片里有很多个小图,来显示动画轨迹.按时间来移动图片,那图片不是会动了啊?(不知道,表达清楚了没…语文很重要啊!!)
准备
我们需要一张图片,一个大脑,一张会笑的脸(不笑效果就出不来了….)!!下面是我准备的图片(ps水平有限^_^)…
代码
我们看到上面的图片,想象下,它动起来是多么的优美啊…
css
.Gnb_btn_div{
width:90px;
height:75px;
overflow:hidden;
display:block;
position:absolute;
}
.Gnb_btn_img{
width:100%;
height:525px;
display:block;
overflow:hidden;
text-indent:-500px;
}
#gnb_btn_01 .Gnb_btn_img {
background-image:url(// <![CDATA[
function GNB(_7c){
//初始化一些参数
this.iImgNum=7; //小图片个数
this.iImgHeight=75; //小图片高度
this.iOverSpeed=50; //鼠标经过时候切换的时间
this.iOutSpeed=50; //鼠标离开时候切换的时间
this.eventObj=_7c; //取得图片对象
this.MouseOverFlag=false;
this.imageIndex=0;
if(this.eventObj==null){return;}
this.eventObj.parentClass=this;this.eventAssign();
}
GNB.prototype.eventAssign=function(){//注册事件
this.eventObj.onmouseover=this.menuMouseOver;
this.eventObj.onmouseout=this.menuMouseOut;
};
GNB.prototype.menuMouseOver=function(){//鼠标经过
if(this.parentClass.MouseOverFlag!=false){return;}
this.parentClass.MouseOverFlag=true;
this.parentClass.clearTimeOut();
this.parentClass.menuMouseOverTimer();
};
GNB.prototype.menuMouseOut=function(){//鼠标离开
this.parentClass.MouseOverFlag=false;
this.parentClass.clearTimeOut();
this.parentClass.menuMouseOutTimer();
};
GNB.prototype.menuMouseOverTimer=function(){//经过图片位置递增
var _7d=this;
if(this.imageIndex>=this.iImgNum){return;}
this.eventObj.scrollTop=this.imageIndex*this.iImgHeight;
this.imageIndex++;
this.setTimerID=setTimeout(function(){_7d.menuMouseOverTimer();},this.iOverSpeed);
};
GNB.prototype.menuMouseOutTimer=function(){////经过图片位置递减
var _7e=this;if(this.imageIndex<0){return;}
this.eventObj.scrollTop=this.imageIndex*this.iImgHeight;
this.imageIndex--;
this.setTimerID=setTimeout(function(){_7e.menuMouseOutTimer();},this.iOutSpeed);
};
GNB.prototype.clearTimeOut=function(){//取消定时
clearTimeout(this.setTimerID);
};
// ]]>
</script>
xhtml
<div class="Gnb_btn_div" id="gnb_btn_01">
<a class="Gnb_btn_img" href="#1" mce_href="#1">找朋友</a>
</div>
<script type="text/javascript">
// <![CDATA[
var GNB1=new GNB(document.getElementById("gnb_btn_01"));//实例单个按钮,当然也可以多个
// ]]>
</script>
演示
猜你喜欢
- 背景:我们在使用数据库的过程中,很多时候要追求性能,特别在处理大批量数据的时候更希望快速处理。那么对SQL SERVER而言,数据库实现大批
- 1、为什么要掌握进程间通信python的多线程代码效率由于受制于GIL,不能利用多核CPU来加速,而多进程方式可以绕过GIL, 发挥多CPU
- match()方法用于从字符串中查找指定的值本方法类似于indexOf()和lastindexOf(),不同的是它返回的是指定的值,而不是指
- 首先声明,这里的权值共享指的不是CNN原理中的共享权值,而是如何在构建类似于Siamese Network这样的多分支网络,且分支结构相同时
- 本文实例讲述了PHP实现的获取文件mimes类型工具类。分享给大家供大家参考,具体如下:<?php/* * Copyright 201
- 如下所示:import http.client, urllib.parseimport http.client, urllib.parsei
- 前沿以前go工程都是在我mac上打包成镜像然后再推到我的docker hub上去,每次更新都要经过打包->推送到dockert仓库-&
- 今天有个脚本需要遍历获取某指定文件夹下面的所有文件,我记得很早前也实现过文件遍历和目录遍历的功能,于是找来看一看,嘿,不看不知道,看了吓一跳
- 过滤html代码的函数,当然也可以使用正则表达式。<%Function FilterHTML(strToFilter)&nb
- 前言在业务开展中,会遇到类似需求。需求1:UPDATE表TEST_TB01中的记录;满足条件:这些记录不在TEST_TB02中。需求2:UP
- 用window.open打开的窗口中,有时候session变量会丢掉,给asp编程带来的一定的麻烦。用参数传递解决它:<DIV&nbs
- expand表示是否把series类型转化为DataFrame类型下面代码中的n表示去掉下划线"_"的数量代码如下:im
- 本文通过问答的开式来解答在mysql在命名用过程中所遇到的常见问题。谁能连接,从那儿连接?你可以允许一个用户从特定的或一系列主机连接。有一个
- 前言需求: 必须现在需要动态创建16个list,每个list的名字不一样,但是是有规律可循,比如第一个list的名字叫:arriage_li
- SCRIPT 标记 用于包含JavaScript代码. 属性 LANGUAGE&nbs
- 一定要对用户可能输入的诸如引号,尖括号等特殊字符给予足够重视,它们可能引发严重的安全问题。SQL注入的基本手法之一,就是利用对单引号未加过滤
- 前言本文主要讲述numpy数组的计算与转置,讲相同尺寸数组的运算与不同尺寸数组的运算,同时介绍数组转置的三种方法。numpy数组的操作比较枯
- 本文实例为大家分享了Python实现简单层次聚类算法,以及可视化,供大家参考,具体内容如下基本的算法思路就是:把当前组间距离最小的两组合并成
- 如果 select 元素下的所有 option 元素均没有指定 selected 属性,会默认选中第一个。可以通过 select.selec
- 试了谷歌到的几种方法,都没有解决,然后突然想起在启动apache的时候,iis的端口占用情况(因为我的apache也使用了80端口),所以&