/* ===========================================================
* jquery.autofix_anything.js v1
* ===========================================================
* Copyright 2013 Pete Rojwongsuriya.
* http://www.thepetedesign.com
*
* Fix position of anything on your website automatically
* with one js call
*
* https://github.com/peachananr/autofix_anything
*
* ========================================================== */ !function($){ var defaults = {
customOffset: false,
manual: false,
onlyInContainer: true
}; $.fn.autofix_anything = function(options){
var settings = $.extend({}, defaults, options),
el = $(this),
curpos = el.position(),
offset = settings.customOffset,
pos = el.offset(); el.addClass("autofix_sb") $.fn.manualfix = function() {
var el = $(this),
pos = el.offset();
if (el.hasClass("fixed")) {
el.removeClass("fixed")
} else {
el.addClass("fixed").css({
top: 0,
left: pos.left,
right: "auto",
bottom: "auto"
});
} } fixAll = function(el, settings, curpos, pos){
if (settings.customOffset == false) offset = el.parent().offset().top
if($(document).scrollTop() > offset && $(document).scrollTop() <= (el.parent().height() + (offset - $(window).height()))) {
el.removeClass("bottom").addClass("fixed").css({
top: 0,
left: pos.left,
right: "auto",
bottom: "auto"
});
} else {
if($(document).scrollTop() > offset) {
if (settings.onlyInContainer == true ) {
if($(document).scrollTop() > (el.parent().height() - $(window).height())) {
el.addClass("bottom fixed").removeAttr( 'style' ).css({
left: curpos.left
});
}else {
el.removeClass("bottom fixed").removeAttr( 'style' ); }
}
} else {
el.removeClass("bottom fixed").removeAttr( 'style' );
}
} }
if (settings.manual == false) {
$(window).scroll(function() {
fixAll(el, settings, curpos, pos)
});
} }
}(window.jQuery);

  

.autofix_sb.fixed {
position: fixed !important;
left: auto;
top: auto;
right: auto;
bottom: auto;
height: 100%;
overflow:auto;
<script type="text/javascript">
$(document).ready( function() {
$(".sidebar").autofix_anything();
}); </script>

  

} .autofix_sb.fixed.bottom { bottom: 0; position: absolute !important; }

  

Jquery 固定悬浮层以及固定表头的更多相关文章

  1. bootstrap table 实现固定悬浮table 表头并可以水平滚动

    在开发项目中,需要将表格头部固定,而且表格大多数情况下是会水平滚动的.项目的css框架是bootstrap 3,故也可以叫做bootstrap table. 需要实现的是:表格头部固定,并且支持水平滚 ...

  2. Saiku如何固定查询结果table的表头和首列

    在使用saiku查询的时候,当“行”和“列”的维度内容过多时,在查看时只看到数据,不知道是什么数据,维度不清楚,得来回拖动滚动条才行,所以同事提出想要固定“表头”和“首列”. 在网上找了一些现成的插件 ...

  3. jQuery&CSS 顶部和底部固定浮动工具栏 兼容IE6

    http://www.cnblogs.com/lhj588/archive/2013/04/02/2994639.html —————————————————————————————————————— ...

  4. jQuery实现网页右下角悬浮层提示

    最近有同事提到类似网页右下角的消息悬浮提示框的制作.我之前也做过一个类似的例子,很简单.是仿QQ消息.现在感觉之前的那个例子只是说了实现原理,整体上给你的感觉还是太丑,今天为大家带来一个新的例子.是D ...

  5. jQuery弹出层始终垂直居中相对于屏幕或当前窗口

    把弹出层的位置设为fixed,设置top:50%,然后获取当前元素的整体的高度height,用获取的高度height/2,设置margin-top:-height/2.即可把当前的弹出层始终垂直居中于 ...

  6. ios系统微信浏览器、safari浏览器中h5页面上拉下滑导致悬浮层脱离窗口的解决方法

    一. 运行环境: iphone所有机型的qq浏览器,safari浏览器,微信内置浏览器(qq浏览器内核)等. 二. 异常现象: 1. 大幅度上下滑动h5页面,然后停止滑动,有时候会影响到页面滚动,如局 ...

  7. 一款很实用的jQuery鼠标悬浮有动画效果的响应式瀑布流插件

    一款很实用的jQuery鼠标悬浮有动画效果的响应式瀑布流插件 在线预览 下载地址 实例代码 <!doctype html> <html lang="zh"> ...

  8. jQuery Layer 弹层组件

    layer是一款近年来口碑非常不错的web弹层组件,她具备全方位的解决方案,致力于服务各个水平段的开发人员,您的页面会轻松地拥有丰富友好的操作体验. 在与同类组件的比较中,layer总是能轻易获胜.她 ...

  9. JQuery弹出层,实现弹层切换,可显示可隐藏。

    <!DOCTYPE html> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <t ...

随机推荐

  1. 深入浅出ExtJS 第二章 Ext框架基础

    2.1 面向对象的基础架构(对象模型) 2.1.1 创建类 >.定义一个类: Ext.define('demo.Demo',{ name:'Lingo', hello:function () { ...

  2. XML文件注意问题

    一.Elements和Descendant Elements 相当于root节点下的子节点,Desendant元素相当于root节点下的所有子节点(包括root.elments下个子节点也包括root ...

  3. PHP浮点数的精度

    在百度知道上看到这么一个问题 var_dump((0.3-0.2)==0.1); 结果是:false 后来查查手册,原来是浮点数的精度问题.那么0.3-0.2-0.1等于多少呢,结果:2.775557 ...

  4. Win7如何快速修复系统

    Windows 7可能是微软迄 今为止最好的桌面操作系统,但是偶尔出现一些问题还是在所难免的.这里教你如何快速修复出现问题的Windows 7系统,每个操作系统都有重新安装的可能,Windows 7也 ...

  5. SQL 把查出来的信息整合为一张表

    select name ,population from bbc where name='France' union all select name ,population from bbc wher ...

  6. 关于GrideView Item点击后出现错乱重叠的情况

    我在一个搜索页做了一个筛选信息的功能 大概思路如下:在根布局中用Include 引入一个筛选框(如图), 然后把边距设置为 android:layout_marginBottom="-250 ...

  7. OC8_代理基本概念

    // // ProtectedDelegate.h // OC8_代理基本概念 // // Created by zhangxueming on 15/6/24. // Copyright (c) 2 ...

  8. Linux读写锁的使用

    读写锁是用来解决读者写者问题的,读操作可以共享,写操作是排它的,读可以有多个在读,写只有唯一个在写,写的时候不允许读. 具有强读者同步和强写者同步两种形式: 强读者同步:当写者没有进行写操作时,读者就 ...

  9. cicm0804吊起

    CICS调用方法:cicslterm -r RGCIPS /////////////// CECI LINK P(CICM0804) COMM(F0000000000000000000006) --- ...

  10. js 求前n项的 fibnaci 数列和

    function f(n) { var num1 = 1, num2 = 1; if (n == 1) document.write(num1);//n=1,输出1 else if (n > 1 ...