2 columns of equal height - Twitter's Bootstrap 2.0

后端 未结 2 820
终归单人心
终归单人心 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 09:56

    The one that has always worked for me is:

    #myPWrap,#otherPWrap {
      overflow:hidden;
    }
    
    #myP,#otherP {
      margin-bottom: -99999px;
      padding-bottom: 99999px;
    }
    

    You can also try to turn the wrap into a table and the #myP into a table col.

    #myPWrap,#otherPWrap {
     display: table;
    }
    
    #myP,#otherP {
     display: table-cell;
    }
    
    0 讨论(0)
  • 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.

    0 讨论(0)
提交回复
热议问题