/* ===========================================================
* 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. 【转载]】Microsoft SQL Server, 错误:4064的解决方法

    SQL SERVER – Fix : Error: 4064 – Cannot open user default database. Login failed. Login failed for u ...

  2. Android 动画学习笔记

    Android动画的两种:Frame帧动画.Tween动画(位移动画)[实现:存放目录res/anim] Tween动画:(位移.缩放.旋转):通过对场景里的对象不断做图像变换. 四种效果Alpha. ...

  3. iOS定位 - 普通定位(没有地图) - 反地理编码(得到具体位置)

    #import <CoreLocation/CoreLocation.h> 使用到的头文件 要引入CoreLocation这个包 <CLLocationManagerDelegate ...

  4. BeanDefinition的Resource定位——2

    1.FileSystemXmlApplicationContext的实现 public class FileSystemXmlApplicationContext extends AbstractXm ...

  5. highcharts实现统计图效果

    highcharts实现统计图效果 ① 根据需求确定需要使用的案例图 把这个界面的html模板文件复制出来,放入./Application/Admin/View/User下改名为chart.html ...

  6. android 网络_网络源码查看器

    xml设计 <?xml version="1.0"?> -<LinearLayout tools:context=".MainActivity" ...

  7. java使用sigar 遇到问题的解决方案

    先给大家介绍一个开源工具Sigar 官网:http://sigar.hyperic.com/ API:http://www.hyperic.com/support/docs/sigar/index-a ...

  8. ASCII 码表

    下面的 ASCII 码表包含数值在0-127之间的字符的十进制.八进制以及十六进制表示. 十进制 八进制 十六进制 字符 描述 0 0 00 NUL   1 1 01 SOH start of hea ...

  9. bzoj 1006: [HNOI2008]神奇的国度

    这是个标准的弦图,但如果不知道弦图就惨了=_= 趁着这个机会了解了一下弦图,主要就是完美消除序列,求出了这个就可以根据序列进行贪心染色. 貌似这个序列很神,但是具体应用不了解…… 这道题为什么可以这么 ...

  10. 工厂方法(Factory Method)模式

    一.工厂方法(Factory Method)模式 工厂方法(FactoryMethod)模式是类的创建模式,其用意是定义一个创建产品对象的工厂接口,将实际创建工作推迟的子类中. 工厂方法模式是简单工厂 ...