【荐】防FLASH的向上滑动的蓝色大气导航菜单

<!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">
<html>
<head>
<title>【荐】防FLASH的向上滑动的蓝色大气导航菜单_网页代码站(www.webdm.cn)</title>
<style>
body
{margin:100px 0}
.clear:after
{content:"."; display:block; height:0; clear:both; visibility:hidden}.clear{display:inline-block}.clear{display:block}
div#nav
{height:70px; background:url(http://www.webdm.cn/images/20090910/nav_bg.png) repeat-x}
div#nav ul
{width:960px; margin:0 auto; list-style:none}
div#nav ul li
{float:left; height:35px; overflow:hidden; padding:0 2px 0 0; font: bold 12px/35px Arial; background:url

(http://www.webdm.cn/images/20090910/nav_right.png) repeat-y right 0
}
div#nav ul li a
{float:left; height:100%; padding:0 20px; background:url(http://www.webdm.cn/images/20090910/nav_sub.png) repeat-x; color:#fff;

text-decoration
:none}
div#nav ul li a.hover
{clear:both; background-position:0 -35px}
div#nav ul li.on a
{background-position:0 -35px}
div#nav ul li.nobg
{background:none}
</style>
</head>
<body onload="changeTableBg();">
<div id="nav">
<ul class="clear">
<li class="on"><a href="http://www.webdm.cn">网站首页</a></li>
<li><a href="#">最新更新</a></li>
<li><a href="#">网页特效</a></li>
<li><a href="#">CSS教程</a></li>
<li><a href="http://www.webdm.cn">脚本资源</a></li>
<li><a href="http://www.webdm.cn">下载排行</a></li>
<li class="nobg"><a href="http://www.webdm.cn">网站留言</a></li>
</ul>

</div>
</body>
<script type="text/javascript">
function nav(c, config){
this.config = config || {speed: 10, num: 2};
this.container = (typeof(c)=="object") ? c : document.getElementById(c);
this.lineHeight = this.container.offsetHeight;
this.scrollTimeId = null;
var _this = this;
this.__construct = function (){
var inner,el,href;
inner
= _this.container.childNodes[0].innerHTML;
href
= _this.container.childNodes[0].href;
el
= document.createElement("a");
el.innerHTML
= inner;
el.href
= href;
el.className
= 'hover';
_this.container.appendChild(el);
//注册事件
_this.container.onmouseover = function (){_this.start()};
_this.container.onmouseout
= function (){_this.end()};
}();
this.start = function (){
_this.clear();
_this.scrollTimeId
= setTimeout(function(){_this.scrollUp();}, _this.config.speed);
};
this.end = function (){
_this.clear();
_this.scrollTimeId
= setTimeout(function(){_this.scrollDown();}, _this.config.speed);
};
this.scrollUp = function (){
var c = _this.container;

if(c.scrollTop >= _this.lineHeight){c.scrollTop = _this.lineHeight;return;}
c.scrollTop
+= _this.config.num;
_this.scrollTimeId
= setTimeout(function(){_this.scrollUp();}, _this.config.speed);
};
this.scrollDown = function (){
var c = _this.container;
if(c.scrollTop <= 0){c.scrollTop = 0;return;}
c.scrollTop
-= _this.config.num;
_this.scrollTimeId
= setTimeout(function(){_this.scrollDown();}, _this.config.speed);
};
this.clear = function (){clearTimeout(_this.scrollTimeId)};
}
(
function(){
var container = document.getElementById('nav');
var el_li = container.getElementsByTagName('li');
var arr = [];
for( var i = 0; i < el_li.length; i++){
if(el_li[i].className == 'on') continue;
arr[i]
= new nav(el_li[i], {speed: 10, num: 4});
}
})();
</script>
</html>
<br>
<p>
<a href="http://www.webdm.cn">网页代码站</a> - 最专业的代码下载网站 - 致力为中国站长提供有质量的代码!</p>

文章来自:http://www.webdm.cn/webcode/2b925a27-2f6f-4121-8cf7-9ce532f86db6.html

 

posted @ 2011-01-06 09:57  网页代码站  阅读(252)  评论(0编辑  收藏  举报