<!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> <title>网页特效-窗口特效-实用的网页顶部固定悬浮效果</title> <meta http-equiv="content-type" content="text/html;charset=utf-8"> <!--把下面代码加到<head>与</head>之间--> <style type="text/css"> *{margin:0;padding:0;} ul,li{list-style:none;} #content{width:600px;margin:0 auto;border:1px solid #f00;} ul li.zzjs{width:400px;text-align:center;margin:20px 100px;background:#00f;color:#fff;font-size:14px;font-weight:bold;height:100px;line-height:100px;} #fudong{position:absolute;top:0;left:50%;width:900px;margin-left:-450px;height:30px;line-height:30px;text-align:center;background:#000;color:#fff;font-size:14px;font-weight:bold;z-index:2;} </style> </head> <body> <div style="height:2000px;"></div> <!--把下面代码加到<body>与</body>之间--> <div id="fudong">导航条:中国技术教程网,站长建站乐园!</div> <script language="javascript"> var speed = 100; var scrollTop = null; var hold = 0; var fudong; var pos = null; var timer = null; var moveHeight = null; fudong = document.getElementById("fudong"); window.onscroll=scroll_ad; function scroll_ad(){ scrollTop = document.documentElement.scrollTop+document.body.scrollTop; pos = scrollTop - fudong.offsetTop; pos = pos/10 moveHeight = pos>0?Math.ceil(pos):Math.floor(pos); if(moveHeight!=0){ fudong.style.top = fudong.offsetTop+moveHeight+"px"; setTimeout(scroll_ad,speed); } //alert(scrollTop); } </script> <div style="width:728px;margin:10px auto; overflow:hidden;"> <script src='http://www.update8.com/plus/ad_js.php?aid=10023' language='javascript'></script> </div> </body> </html> (www.update8.com)提示:可修改后代码再运行!