当前位置: 首页 > 图文教程 > 网络编程 > Javascript > JQery 渐变图片导航效果代码 漂亮

Javascript
jQuery开发者都需要知道的5个小技巧
Extjs学习笔记之六 面版
Javascript 中的类和闭包
IE6下JS动态设置图片src地址问题
Extjs学习笔记之七 布局
Extjs学习笔记之八 继承和事件基础
Extjs TriggerField在弹出窗口显示不出问题的解决方法
JavaScript中的集合及效率
利用js获取服务器时间的两个简单方法
在html页面上拖放移动标签
了解jQuery技巧来提高你的代码
JavaScript 页面坐标相关知识整理
Javascript UrlDecode函数代码
JQuery 遮罩层实现(mask)实现代码
jQuery 页面 Mask实现代码
Javascript的构造函数和constructor属性
js或css文件后面跟参数的原因说明
将CKfinder整合进CKEditor3.0的新方法
jQuery UI-Draggable 参数集合
jQuery 行级解析读取XML文件(附源码)

Javascript 中的 JQery 渐变图片导航效果代码 漂亮


出处:互联网   整理: 软晨网(RuanChen.com)   发布: 2010-01-10   浏览: 187 ::
收藏到网摘: n/a

JQery 渐变图片导航,效果不错,非常漂亮。

图片如上。。下载图片试试。。效果不错哦。。JS就直接连接远程就可以了

代码复用性差。。希望高手指点下,应该怎么样才好

复制代码 代码如下:

<!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>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>测试导航</title>
<script src="/upload/tech/20100110/20100110112758_5d44ee6f2c3f71b73125876103c8f6c4.js" type="text/javascript"></script>
<script type="text/javascript">
$(document).ready(function()
{
var datacss=["home","game","zine","community","calendar","participate"];
for(var i=0;i<datacss.length;i++)
{
$("#"+datacss[i]).append("<div class='"+datacss[i]+"'></div>");
$("."+datacss[i]).css('opacity', 0);
$("#"+datacss[i]).hover(
function()
{
$("."+this.id).stop().animate({opacity: '1'},800);
},
function()
{
$("."+this.id).stop().animate({opacity: '0'},800);
});
}
});
</script>
<style type="text/css">
body { } ul li{ list-style:none; float:left; margin:0; padding:0;}
#home{background: url(navigation.jpg) top left no-repeat;
width:90px; height:55px;
}
.home {background: url(navigation.jpg) 0 -55px no-repeat;
width: 90px;height: 55px;
}
#game{background: url(navigation.jpg) -90px 0px; no-repeat;
width:114px; height:55px;
}
.game{background: url(navigation.jpg) -90px -55px no-repeat;
width:114px; height:55px;
}
#zine{background: url(navigation.jpg) -204px 0px; no-repeat;
width:96px; height:55px;
}
.zine{background: url(navigation.jpg) -204px -55px no-repeat;
width:96px; height:55px;
}
#community{background: url(navigation.jpg) -300px 0px; no-repeat;
width:144px; height:55px;
}
.community{background: url(navigation.jpg) -300px -55px no-repeat;
width:144px; height:55px;
}
#calendar{background: url(navigation.jpg) -446px 0px; no-repeat;
width:137px; height:55px;
}
.calendar{background: url(navigation.jpg) -446px -55px no-repeat;
width:137px; height:55px;
}
#participate{background: url(navigation.jpg) -583px 0px; no-repeat;
width:135px; height:55px;
}
.participate{background: url(navigation.jpg) -583px -55px no-repeat;
width:135px; height:55px;
}
</style>
</head>
<body>
<ul>
<li><a href="#"><div id="home"></div></a></li>
<li><a href="#"><div id="game"></div></a></li>
<li><a href="#"><div id="zine"></div></a></li>
<li><a href="#"><div id="community"></div></a></li>
<li><a href="#"><div id="calendar"></div></a></li>
<li><a href="#"><div id="participate"></div></a></li>
</ul>
</body>
</html>