限时优惠活动
亲爱的苦力吧用户,我们为了回馈新老用户一直以来的鼎力支持,即日起(2025-02-06至2025-03-06)凡是购买苦力吧VIP/充值K币的新老用户,都直接可获得买一送一的优惠馈赠。例如:购买一个月的VIP会员可直接获得两个月的VIP会员;充值100K币可直接获得200K币,以此类推!有任何疑问可联系在线客服,感谢各位用户对苦力吧素材的信任与厚爱,我们将一如既往的给大家上新更多优质的素材源码,祝大家开工大吉、工作顺利、心想事成。

jquery轻量级DIV容器自动等高插件

所属分类: 网页特效-其它&杂项    2023-11-16 11:16:17

jquery轻量级DIV容器自动等高插件 ie兼容6
 查看演示  登录后下载 温馨提示
登录会员即可享受免费下载
 我要建站

jquery轻量级DIV容器自动等高插件(共3个文件)

    • index.html

使用方法

;(function($) {"use strict"; 
// Name and default settings
var pluginName = 'align';
var resizeName = pluginName + 'ResizeDone';
var defaults = {
    bottom: false,
    selector: '> *'
};

// Resize timer
var resizeTimer;

// Map commands to methods
var commands = {
    update: 'update',
    reset: 'reset'
};

// Constructor
var Plugin = function(element, options) {
    this.element = element;
    this.settings = $.extend({}, defaults, options);
    this._defaults = defaults;
    this._name = pluginName;

    // Initialization
    this.init();
};

// Initialization
Plugin.prototype.init = function() {
    var _this = this;

    this.select();

    // Align boxes when the complete page has loaded and when the window has
    // finished resizing. It's no good trying to align everything on
    // document ready because you might still be waiting for CSS that will
    // affect the height of the boxes.
    $(window).on('load ' + resizeName, function() {
        _this.align();
    });

    // Attempt to align the boxes immediately as well, in case we are
    // running on window load instead of on DOM content ready.
    _this.align();
};

// Select boxes to align
Plugin.prototype.select = function() {
    this.boxes = $(this.element).find(this.settings.selector);
    this.save();
};

// Save initial styles
Plugin.prototype.save = function() {
    this.boxes.each(function(i, boxElement) {
        var box = $(boxElement);

        if (box.attr('style') && !box.data('style')) {
            box.data('style', box.attr('style'));
        }
    });
};

// Reset boxes to their initial styles
Plugin.prototype.reset = function() {
    this.naturalize();
    this.boxes.each(function(i, boxElement) {
        var box = $(boxElement);

        // Restore original style attribute
        if (box.data('style')) {
            return box.attr('style', box.data('style'));
        }

        // Remove style attribute added by this plugin
        box.removeAttr('style');
    });
};

// Set all boxes to their natural height
Plugin.prototype.naturalize = function() {
    this.boxes.each(function(i, boxElement) {
        $(boxElement).height('auto');
    });
};

// Align boxes
Plugin.prototype.align = function() {
    var _this = this;
    var boxes = _this.boxes;
    var done = [];

    // Reset box heights
    this.naturalize();

    boxes.each(function(i, boxElement) {
        var box = $(boxElement);
        var max = 0;

        // Assemble collection of elements in the same row
        var row = box.add(boxes.not(box).filter(function() {
            var heightA = box.offset().top;
            var heightB = $(this).offset().top;

            // Align to bottom edge instead?
            if (_this.settings.bottom) {
                heightA += box.height();
                heightB += $(this).height();
            }

            return heightA === heightB;
        }));

        // If only box in row or already resized, do nothing
        if (row.length === 1 || $.inArray(boxElement, done) !== -1) {
            return;
        }

        // Find the tallest element in the row
        row.each(function(i, siblingElement) {
            var sibling = $(siblingElement);
            var height = sibling.outerHeight();

            if (height > max) {
                max = height;
            }

            // We are finished with this element, so don't check it again
            done.push(siblingElement);
        });

        // Set all elements to same height as tallest element in row
        row.each(function(i, siblingElement) {
            return $(siblingElement).outerHeight(max);
        });
    });
};

// Update selection and re-align all boxes
Plugin.prototype.update = function() {
    this.select();
    this.align();
};

// Add method to jQuery
$.fn[pluginName] = function(options) {
    return this.each(function() {
        var instance = $.data(this, pluginName);

        // Named commands
        if (typeof options === 'string') {
            if (
                typeof instance === 'undefined' ||
                typeof commands[options] === 'undefined'
            ) {
                return false;
            }

            return instance[commands[options]]();
        }

        // Create instance
        if (!instance) {
            $.data(this, pluginName, new Plugin(this, options));
        }
    });
};

// Trigger window resize complete event
$(window).on('resize', function() {
    window.clearTimeout(resizeTimer);

    resizeTimer = window.setTimeout(function() {
        $(window).trigger(resizeName);
    }, 50);
});

})(jQuery);

站长提示:
1. 苦力吧素材官方QQ群:950875342
2. 平台上所有素材资源,需注册登录会员方能正常下载。
3. 会员用户积极反馈网站、素材资源BUG或错误问题,每次奖励2K币
4. PHP源码类素材,如需协助安装调试,或你有二次开发需求,可联系苦力吧客服。
5. 付费素材资源,需充值后方能下载,如有任何疑问可直接联系苦力吧客服
相关资源 / 其它&杂项

jquery滚动页面触发元素顶部固定浮动特效插件

一款滚动触发的粘性浮动栏插件,当鼠标拉动滚动条时,即时触发当前区域绑定的元素,置于最上层,且吸顶浮动于页面顶部。
  其它&杂项
 3322  0

javascript实现的购物车代码

这是一款js原生代码实现的在线购物车,此代码将事件监听器添加到类为“addtocart”的按钮,单击可将当前商品添加到购物车,并监听id为“emptycart”的按钮,可清空购物车。当用户单击“addtocart”按钮时,会调用“addtocart”函数。
  其它&杂项
 8336  0

jquery根据h2元素自动生成目录插件

一个自动目录生成器插件,可自动从文档中找到的所有h2元素生成一个可点击的目录,并将其放在h1元素大标题之后。
  其它&杂项
 8360  0

jquery点击按钮可对table删除/增加表格行插件

一款table新增删除行插件,自动给每行table表格行增加一列,可删除、增加行按钮,鼠标点击+/-按钮动态复制/删除表格行。
  其它&杂项
 3138  0

评论数(0) 回复有机会获得K币 用户协议

^_^ 还没有人评论,快来抢个沙发!
😀
  • 😀
  • 😊
  • 😂
  • 😍
  • 😑
  • 😷
  • 😵
  • 😛
  • 😣
  • 😱
  • 😋
  • 😎
  • 😵
  • 😕
  • 😶
  • 😚
  • 😜
  • 😭
发表评论