javascript - 使用 css 或 jquery、javascript 平均增加所有框的高度

标签 javascript jquery html css

我的 html 结构不会改变。

<article class="col-md-3 col-sm-3 diagnostic-block worth">
    <blockquote>
        <header>
            <h6>
                <a onclick="javascript:doOpenURL('xyz.aspx?Section=11','contentArea','1020','700','1');" href="javascript:void(null)">Page heading will goes</a>
            </h6>
        </header>
        <footer>
            <small>Text hereText hereText hereText hereText hereText here</small>
            <p>Worth a look</p>
        </footer>
    </blockquote>
</article>

enter image description here

enter image description here

最佳答案

http://codepen.io/pen/KwNRjQ这应该可以实现您想要的效果。

$.fn.eqHeights = function(options) {

var defaults = {  
    child: false ,
  parentSelector:null
};  
var options = $.extend(defaults, options); 

var el = $(this);
if (el.length > 0 && !el.data('eqHeights')) {
    $(window).bind('resize.eqHeights', function() {
        el.eqHeights();
    });
    el.data('eqHeights', true);
}

if( options.child && options.child.length > 0 ){
    var elmtns = $(options.child, this);
} else {
    var elmtns = $(this).children();
}

var prevTop = 0;
var max_height = 0;
var elements = [];
var parentEl;
elmtns.height('auto').each(function() {

  if(options.parentSelector && parentEl !== $(this).parents(options.parentSelector).get(0)){
    $(elements).height(max_height);
    max_height = 0;
    prevTop = 0;
    elements=[];
    parentEl = $(this).parents(options.parentSelector).get(0);
  }

    var thisTop = this.offsetTop;

    if (prevTop > 0 && prevTop != thisTop) {
        $(elements).height(max_height);
        max_height = $(this).height();
        elements = [];
    }
    max_height = Math.max(max_height, $(this).height());

    prevTop = this.offsetTop;
    elements.push(this);
});

$(elements).height(max_height);
};

关于javascript - 使用 css 或 jquery、javascript 平均增加所有框的高度,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27778433/

相关文章:

javascript - 更改组文本字段的背景颜色

jquery - 同时使用显示 : none and display:flex;

javascript - 悬停时如何使用 <a> 标签元素缩小图像?

jQuery 对象属性而不是类

javascript - 装饰器不支持 Angular 6 Prod 函数调用,但调用了 '..Module'

javascript - 使用 javascript 后 css 悬停事件不起作用?

javascript - 如何在 WinJS 中移动和删除文件

javascript - 通过rowindex查找一行,然后在jquery中查找特定的td

javascript - 在幻灯片中用 <a> 标签包裹 <li>

javascript - 防止菜单显示在窗口外