本文实例讲述了js实现分享到随页面滚动而滑动效果的方法。分享给大家供大家参考。具体如下:
页面向上向下滚动,分享到的模块随着滑动。
要点:
复制代码 代码如下:var scrtop =document.documentElement.scrollTop||document.body.scrollTop;
var height = document.documentElement.clientHeight||document.body.clientHeight;
var top = scrtop + (height - jb51.offsetHeight)/2;
top = parseInt(top);
获得页面垂直居中的位置
上代码:
无标题文档 body{margin:0; padding:0; font:12px/1.5 arial; height:2000px;} #jb51{width:100px; height:200px; line-height:200px; text-align:center; border:1p solid #ccc; background:#f5f5f5; position:absolute; left:-100px; top:0;} #jb51_tit{position:absolute; right:-20px; top:60px; width:20px; height:60px; padding:10px 0; background:#06c; text-align:center; line-height:18px; color:#fff;} 分享到内容 分享到
希望本文所述对大家的javascript程序设计有所帮助。



