2 columns of equal height - Twitter's Bootstrap 2.0

后端 未结 2 822
终归单人心
终归单人心 2021-02-07 09:40

Well, everybody knows that Twitter\'s Bootstrap is a great tool and makes a lot of things easier for those who, like me, doesn\'t know much about CSS yet. But, sometimes, it can

2条回答
  •  无人共我
    2021-02-07 10:03

    I solved this with a custom jQuery max plugin:

    $.fn.max = function(selector) { 
        return Math.max.apply(null, this.map(function(index, el) { return selector.apply(el); }).get() ); 
    }
    

    Here content-box is my internal column element, content-container is the wrapper that contains the columns:

    $('.content-box').height(function () {
      var maxHeight = $(this).closest('.content-container').find('.content-box')
                      .max( function () {
                        return $(this).height();
                      });
      return maxHeight;
    })
    

    Hope this helps.

提交回复
热议问题