|
|
Ruclinux 发表于 2012-9-6 00:19 
不懂,能写个实例吗?按照我贴出来的您给改一下也成,谢谢了. ...
需要JQuery支持,懒得费事写,直接现扒的。
HTML:- <div id="shangxia"><div id="shang"></div><div id="xia"></div></div>
复制代码 CSS:- #shangxia {
- position: absolute;
- top: 40%;
- left: 50%;
- margin-left: -540px;
- display: block;
- }
复制代码 JS:- jQuery(document).ready(function($){
- var s=$('#shangxia').offset().top;$(window).scroll(function(){$("#shangxia").animate({top:$(window).scrollTop()+s+"px"},{queue:false,duration:500})});$body=(window.opera)?(document.compatMode=="CSS1Compat"?$('html'):$('body')):$('html,body');$('#shang').click(function(){$body.animate({scrollTop:'0px'},400)});$('#xia').click(function(){$body.animate({scrollTop:$('#footer').offset().top},400)});$('#comt').click(function(){$body.animate({scrollTop:$('#comments').offset().top},400)});
复制代码 |
|