javascript跟隨滾動效果插件代碼(javascript Follow Plugin)
更新時間:2013年08月03日 10:55:23 作者:
這篇文章介紹了javascript跟隨滾動效果插件代碼(javascript Follow Plugin),有需要的朋友可以參考一下
Js 跟隨滾動效果插件
支持定義多個跟隨ID,采用css fixed屬性,不支持ie6,兼容其他主流瀏覽器。
支持定義滾動到底部的最小高度,不會覆蓋底部
頁面大小resize后,插件會自動重置參數(shù)
=======
Js 跟隨滾動效果插件
1.支持定義多個跟隨ID,采用css fixed屬性,不支持ie6,兼容其他主流瀏覽器。
2.支持定義滾動到底部的最小高度,不會覆蓋底部
3.頁面大小resize后,插件會自動重置參數(shù)
=======
使用方法
代碼如下
<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
});
}
完整實例
代碼如下
<!DOCTYPE html>
<html lang="zh-CN">
<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 class="wrap">
<div class="header">Header</div>
<div class="content clear">
<div class="left">
<div class="text">
使用方法:<br/>
1.載入插件,在頁面載入之后,window.onload = function(){}<br/>
2.創(chuàng)建需要跟隨的對象的數(shù)組,比如 var followIds = [document.getElementById("follow"),document.getElementById("follow2")];<br/>
3.初始化Follow:new Follow();<br/>
4.傳參,obj是對象數(shù)組,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 class="right">
<div class="aside" id="follow">
跟隨滾動<br/>模塊1
</div>
<div class="aside2" id="follow2">
跟隨滾動<br/>模塊2
</div>
</div>
</div>
<div class="footer">Footer</div>
</div>
<script type="text/javascript" src="follow.min.js"></script>
<script>
window.onload = function(){
var followIds = [document.getElementById("follow"),document.getElementById("follow2")];
new Follow({
obj:followIds,
bottom:150
});
}
</script>
</body>
</html>
支持定義多個跟隨ID,采用css fixed屬性,不支持ie6,兼容其他主流瀏覽器。
支持定義滾動到底部的最小高度,不會覆蓋底部
頁面大小resize后,插件會自動重置參數(shù)
=======
Js 跟隨滾動效果插件
1.支持定義多個跟隨ID,采用css fixed屬性,不支持ie6,兼容其他主流瀏覽器。
2.支持定義滾動到底部的最小高度,不會覆蓋底部
3.頁面大小resize后,插件會自動重置參數(shù)
=======
使用方法
代碼如下
復(fù)制代碼 代碼如下:
<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
});
}
完整實例
代碼如下
復(fù)制代碼 代碼如下:
<!DOCTYPE html>
<html lang="zh-CN">
<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 class="wrap">
<div class="header">Header</div>
<div class="content clear">
<div class="left">
<div class="text">
使用方法:<br/>
1.載入插件,在頁面載入之后,window.onload = function(){}<br/>
2.創(chuàng)建需要跟隨的對象的數(shù)組,比如 var followIds = [document.getElementById("follow"),document.getElementById("follow2")];<br/>
3.初始化Follow:new Follow();<br/>
4.傳參,obj是對象數(shù)組,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 class="right">
<div class="aside" id="follow">
跟隨滾動<br/>模塊1
</div>
<div class="aside2" id="follow2">
跟隨滾動<br/>模塊2
</div>
</div>
</div>
<div class="footer">Footer</div>
</div>
<script type="text/javascript" src="follow.min.js"></script>
<script>
window.onload = function(){
var followIds = [document.getElementById("follow"),document.getElementById("follow2")];
new Follow({
obj:followIds,
bottom:150
});
}
</script>
</body>
</html>
相關(guān)文章
將json當(dāng)數(shù)據(jù)庫一樣操作的javascript lib
使用javascript操作JSON的類庫TAFFY DB,具體介紹了:查詢數(shù)據(jù)、添加數(shù)據(jù)、刪除數(shù)據(jù)、修改數(shù)據(jù)。2013-10-10JavaScript實現(xiàn)定時器循環(huán)展示數(shù)組
這篇文章主要為大家詳細(xì)介紹了JavaScript實現(xiàn)定時器循環(huán)展示數(shù)組,文中示例代碼介紹的非常詳細(xì),具有一定的參考價值,感興趣的小伙伴們可以參考一下2022-09-09解決WebStorm?2022.3.x?無法識別?Element?UI?2.15.11?新版本中的?el-
這篇文章主要介紹了解決?WebStorm?2022.3.x?無法識別?Element?UI?2.15.11?新版本中的?el-xxx?標(biāo)簽問題,本文給大家分享兩種解決方案,需要的朋友可以參考下2023-01-01JavaScript數(shù)組Array的一些常用方法總結(jié)
JavaScript的Array對象是用于構(gòu)造數(shù)組的全局對象,數(shù)組是類似于列表的高階對象,下面這篇文章主要給大家介紹了關(guān)于JavaScript數(shù)組Array的一些常用方法,需要的朋友可以參考下2021-11-11JavaScript數(shù)組、json對象、eval()函數(shù)用法實例分析
這篇文章主要介紹了JavaScript數(shù)組、json對象、eval()函數(shù)用法,結(jié)合實例形式分析了JS數(shù)組創(chuàng)建、賦值、連接、翻轉(zhuǎn),json對象定義、讀取,eval()函數(shù)的功能、使用等,需要的朋友可以參考下2019-02-02JavaScript基于ChatGPT?API實現(xiàn)劃詞翻譯瀏覽器腳本
最近?GitHub?上有個基于?ChatGPT?API?的瀏覽器腳本,openai-translator,?短時間內(nèi)?star?沖到了?9.7k,拋開?tauri?是使用?rust?部分,那瀏覽器部分實現(xiàn)還是比較簡單的,今天我們就來手動實現(xiàn)一下2023-03-03BootStrap下的彈出框加載select2框架失敗的解決方法
本文通過簡單的代碼給大家介紹了BootStrap下的彈出框加載select2框架失敗的解決方法,需要的朋友參考下吧2017-08-08