javascript 跟随滚动效果功能实例

javascript跟随滚动效果插件代码(javascript Follow Plugin),有需要的朋友可以参考一下
Js 跟随滚动效果插件
支持定义多个跟随ID,采用css fixed属性不支持ie6,兼容其他主流浏览器。
支持定义滚动到底部的最小高度,不会覆盖底部
页面大小resize后,插件自动重置参数
=======
Js 跟随滚动效果插件
1.支持定义多个跟随ID,采用css fixed属性不支持ie6,兼容其他主流浏览器。
2.支持定义滚动到底部的最小高度,不会覆盖底部
3.页面大小resize后,插件自动重置参数
=======
使用方法

<script type=text/javascript src=follow.js></script>
/**
 * 跟随滚动效果
 *
 * @param 
 * @arrange (编程之家) jb51.cc
 **/
window.onload = function(){
var followIds = [document.getElementById(follow),document.getElementById(follow2)];
new Follow({
obj:followIds,bottom:150
});
}
完整实例:

<!DOCTYPE html>
<html>
<head profile=http://gmpg.org/xfn/11>
<Meta charset=UTF-8>
<title>Js Follow跟随滚动效果</title>
<style>
html,body{width:100%;margin:0;padding:0;}
div{padding:0;margin:0;text-align:center;font-size:40px;font-weight:bold;color:#fff;}
.clear:after{content:;display:block;height:0;clear:both;visibility: hidden;overflow:hidden;}
.clear{*zoom:1;}
.wrap{width:1000px;margin:0 auto;}
.header{width:100%;background:#1BA1E2;height:200px;line-height:300px;}
.footer{width:100%;background:#666;height:150px;line-height:100px;}
.content{width:100%;margin:0 auto;background:#aaa;}
.left{width:70%;float:left;background:#8CBF26;}
.text{padding:50px;text-align:left;word-break:break-all;line-height:36px;font-size:16px;font-weight:normal;}
.right{width:30%;float:left;}
.aside{padding:10px 0px;margin-top:50px;background:#F09609;width:300px;height:150px;}
.aside2{padding:10px 0px;background:#DB4F33;}
</style>
</head>
<body>
<div>
<div>Header</div>
<div class=content clear>
<div>
<div>
使用方法:<br/>
 1.载入插件,在页面载入之后,window.onload = function(){}<br/>
    2.创建需要跟随的对象的数组,比如 var followIds = [document.getElementById(follow),document.getElementById(follow2)];<br/>
    3.初始化Follow:new Follow();<br/>
    4.传参,obj是对象数组,bottom是滚动块距离底部的最小的高度<br/>
    <hr/>
<pre style=word-break:break-all;word-wrap:break-word;width:600px;>
<script type=text/javascript src=follow.js></script>
window.onload = function(){
 var followIds = [document.getElementById(follow),document.getElementById(follow2)];
 new Follow({
  obj:followIds,bottom:150
 });
}
</pre>
    </div>
    <br/><br/><br/><br/><br/><br/><br/><br/><br/>
   </div>
   <div>
    <div id=follow>
     跟随滚动<br/>模块1
    </div>
    <div id=follow2>
     跟随滚动<br/>模块2
    </div>
   </div>
  </div>
  <div>Footer</div>
 </div>
<script type=text/javascript src=follow.min.js></script>
<script>
window.onload = function(){
 var followIds = [document.getElementById(follow),bottom:150
 });
}
</script>
</body>
</html>

<!--   来自 编程之家 jb51.cc (jb51.cc)-->

相关文章

前言 做过web项目开发的人对layer弹层组件肯定不陌生,作为l...
前言 前端表单校验是过滤无效数据、假数据、有毒数据的第一步...
前言 图片上传是web项目常见的需求,我基于之前的博客的代码...
前言 导出Excel文件这个功能,通常都是在后端实现返回前端一...
前言 众所周知,js是单线程的,从上往下,从左往右依次执行,...
前言 项目开发中,我们可能会碰到这样的需求:select标签,禁...