<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>《基于Web标准的网页设计》唐四薪编著 ISBN:978-7-302-21181-5 页数:16开428页 定价:38元 出版社:清华大学出版社 出版时间:2009年11月</title>
<style type="text/css">
.clear:after{content:"."; display:block; height:0; clear:both; visibility:hidden}.clear{display:inline-block}.clear{display:block}
div#nav{height:32px; background:url(http://www.eagexp.com/YLimage/YL29.jpg) repeat-x}
div#nav ul{
width:705px;
list-style:none;
margin-top: 0;
margin-right: auto;
margin-bottom: 0;
margin-left: 0px;
}
div#nav ul li{
float:left;
height:32px;
overflow:hidden;
background-image: url(http://www.eagexp.com/YLimage/YL30.jpg);
background-repeat: repeat-y;
background-position: right 0;
padding-top: 0;
padding-right: 1px;
padding-bottom: 0;
padding-left: 0px;
font-family: Arial;
font-size: 12px;
line-height: 32px;
font-weight: bold;
}
div#nav ul li a{
float:left;
height:100%;
width: 77px;
background:url(http://www.eagexp.com/YLimage/YL28.jpg) repeat-x;
color:#fff;
text-decoration:none;
padding-top: 0;
padding-right: 5px;
padding-bottom: 0;
padding-left: 5px;
text-align:center;
}
div#nav ul li a.hover{
clear:both;
background-position:0 -32px;
width: 77px;
}
div#nav ul li.on a{
background-position:0 -32px;
}
div#nav ul li.nobg{background:none}
/* ]]> */
</style>
</head><body>
<div id="nav">
<ul class="clear">
<li><a href="#">首页</a></li>
<li><a href="#">中心简介</a></li>
<li><a href="#">常用下载</a></li>
<li><a href="#">新闻中心</a></li>
<li><a href="#">服务支持</a></li>
<li><a href="#">政策法规</a></li>
<li><a href="#">故障报修</a></li>
<li><a href="#">网页教学</a></li><li class="nobg"><a href="#">联系我们</a></li>
</ul>
</div>
<script type="text/javascript">
/* <![CDATA[ */
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>
http://ec.hynu.cn
</body>
</html>
谁能把这个效果的原理看懂吗,我觉得如果当鼠标悬停时让另一个元素显示,并慢慢滑动遮盖住底下的这个元素,倒是能实现这个效果,可关键是在这段代码的结构代码中只有一个a元素,显然不是通过用另外一个元素动态遮盖这个a元素实现的,不知它的原理怎么样
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>《基于Web标准的网页设计》唐四薪编著 ISBN:978-7-302-21181-5 页数:16开428页 定价:38元 出版社:清华大学出版社 出版时间:2009年11月</title>
<style type="text/css">
.clear:after{content:"."; display:block; height:0; clear:both; visibility:hidden}.clear{display:inline-block}.clear{display:block}
div#nav{height:32px; background:url(http://www.eagexp.com/YLimage/YL29.jpg) repeat-x}
div#nav ul{
width:705px;
list-style:none;
margin-top: 0;
margin-right: auto;
margin-bottom: 0;
margin-left: 0px;
}
div#nav ul li{
float:left;
height:32px;
overflow:hidden;
background-image: url(http://www.eagexp.com/YLimage/YL30.jpg);
background-repeat: repeat-y;
background-position: right 0;
padding-top: 0;
padding-right: 1px;
padding-bottom: 0;
padding-left: 0px;
font-family: Arial;
font-size: 12px;
line-height: 32px;
font-weight: bold;
}
div#nav ul li a{
float:left;
height:100%;
width: 77px;
background:url(http://www.eagexp.com/YLimage/YL28.jpg) repeat-x;
color:#fff;
text-decoration:none;
padding-top: 0;
padding-right: 5px;
padding-bottom: 0;
padding-left: 5px;
text-align:center;
}
div#nav ul li a.hover{
clear:both;
background-position:0 -32px;
width: 77px;
}
div#nav ul li.on a{
background-position:0 -32px;
}
div#nav ul li.nobg{background:none}
/* ]]> */
</style>
</head><body>
<div id="nav">
<ul class="clear">
<li><a href="#">首页</a></li>
<li><a href="#">中心简介</a></li>
<li><a href="#">常用下载</a></li>
<li><a href="#">新闻中心</a></li>
<li><a href="#">服务支持</a></li>
<li><a href="#">政策法规</a></li>
<li><a href="#">故障报修</a></li>
<li><a href="#">网页教学</a></li><li class="nobg"><a href="#">联系我们</a></li>
</ul>
</div>
<script type="text/javascript">
/* <![CDATA[ */
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>
http://ec.hynu.cn
</body>
</html>
谁能把这个效果的原理看懂吗,我觉得如果当鼠标悬停时让另一个元素显示,并慢慢滑动遮盖住底下的这个元素,倒是能实现这个效果,可关键是在这段代码的结构代码中只有一个a元素,显然不是通过用另外一个元素动态遮盖这个a元素实现的,不知它的原理怎么样
alert(document.body.outerHTML);
应该可以看出猫腻了吧^_^