限时优惠活动
亲爱的苦力吧用户,我们为了回馈新老用户一直以来的鼎力支持,即日起(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拖动添加购物车商品加减结算代码

一款拖拽图片加入购物车特效,自动结算,非常的实用!
  其它&杂项
 3283  0

jquery鼠标点击文本链接快速编辑插件

一款点击链接进行编辑的jq插件,非常方便实用!
  其它&杂项
 4324  0

javascript可拖拽移动的许愿墙代码

一款可拖动的许愿墙代码,输入标题和内容可发布许愿信息,支持删除、移动。
  其它&杂项
 1124  0

jquery网页底部右下角固定浮动的DIV模块

一款页面右下角浮动层特效,DIV位于最上层、浮动固定,可点击关闭按钮隐藏。
  其它&杂项
 5147  0

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

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