scrollfix.js插件:滚动固定在某个位置
插件文件在/文件 scrollfix.js
用法:
var fix = $(".fix"), fixtop = $(".fix-top"), fixStartTop = $(".fix-startTop"), fixStartBottom = $(".fix-startBottom"), fixbottom = $(".fix-bottom"), fixfooter = $(".fix-footer");
fix.scrollFix(); //第一种
fixtop.scrollFix({distanceTop:20}); //第二种
fixStartTop.scrollFix({startTop:"#startTop"}); //第三种
fixStartBottom.scrollFix({startBottom:"#startBottom"}); //第四种
fixbottom.scrollFix({endPos:300});//第五种
fixfooter.scrollFix({endPos:"#fixFooter"}); //第六种
fixbottom.scrollFix({distanceTop:20,startTop:"#startTop",endPos:300}); //第七种
fixfooter.scrollFix({distanceTop:10, startBottom:"#startBottom", endPos:"#fixFooter"}) //第八种
参数详解
| 参数名字 | 参数值 | 参数作用 | 
|---|---|---|
| startTop | null | 开始固定的jquery对象的顶部 | 
| startBottom | null | 开始固定的jquery对象末端,两个参数都设置的话,默认后面参数生效 | 
| distanceTop | 0/null | 数值,距离顶部的高度,可以为高度或者jquery对象 | 
| endPos | null/0 | 距离底部的高度,可以为高度或者jquery对象 | 
| bottom | -1 | 默认不使用位置为bottom的值,当设置为0,将会停在窗口底端 | 
| zIndex | 0 | 当没有设置这个值时,将默认使用元素的css z-index值 | 
| baseClassName | 'scrollfixed' | 当元素开始固定时给它添加一个class,你可以设置为你喜欢的类名。 | 
第一种:默认滚动到这里开始固定
第四种:滚动到一个标签#startBottom的末端开始固定
第五种:滚动停在底部300像素
                    
                
                
            
        
浙公网安备 33010602011771号