jQuery跟随屏幕滚动的层

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3c.org/TR/1999/REC-html401-19991224/loose.dtd">
<!-- saved from url=(0040)http://www.cssrain.cn/demo/floatDIV.html -->
<HTML
xmlns="http://www.w3.org/1999/xhtml"><HEAD><TITLE>jquery.text-effects</TITLE>
<META content="text/html; charset=utf-8" http-equiv=Content-Type>
<STYLE>* {
PADDING-BOTTOM: 0px; MARGIN: 0px; PADDING-LEFT: 0px; PADDING-RIGHT: 0px; PADDING-TOP: 0px
}
#test {
POSITION: absolute; WIDTH: 130px; BACKGROUND: #555; HEIGHT: 60px; COLOR: #fff; FONT-SIZE: 13px; TOP: 10px; RIGHT: 10px
}
</STYLE>

<SCRIPT type=text/javascript
src="jquery_text-effects_files/jquery-1.3.1.js"></SCRIPT>

<SCRIPT language=javascript>
$(document).ready(function(){
var menuYloc = $("#test").offset().top;
$(window).scroll(function (){
   var offsetTop = menuYloc + $(window).scrollTop() +"px";
   $("#test").animate({top : offsetTop },{ duration:600 , queue:false });
});
});
</SCRIPT>

<META name=GENERATOR content="MSHTML 8.00.6001.18702"></HEAD>
<BODY>
<H1>7行代码的跟随屏幕滚动层.</H1><BR><BR><BR><BR><BR><BR><BR><BR><BR><BR><BR><BR><BR><BR><BR><BR><BR>
<DIV id=test>Dev By CssRain.cn<BR>Test
ie6+,firefox3.0</DIV><BR><BR><BR><BR><BR><BR><BR><BR><BR><BR><BR><BR><BR><BR><BR><BR><BR><BR><BR><BR><BR><BR><BR><BR><BR><BR><BR><BR><BR><BR><BR><BR><BR><BR></BODY></HTML>

你可能感兴趣的:(jquery)