oneadvent
oneadvent

Reputation: 529

make jquery use min-height not just height

The code:

function setEqualHeight(columns) {
    var tallestcolumn = 0;
    columns.each(function(){
        currentHeight = $(this).height();
        if(currentHeight > tallestcolumn){
            tallestcolumn  = currentHeight;
        }
    });
    if (tallestcolumn <= 1000) {
        columns.height(tallestcolumn + 4);
    }
}
$(document).ready(function() {
    setEqualHeight($("#main-content-bottom-bg  > div"));
});

I know its probably simple, but I just cannot figure out what I give. I would think something like this:

columns.minheight(tallestcolumn + 4);

Thanks.

Upvotes: 0

Views: 178

Answers (3)

Ahmad Alfy
Ahmad Alfy

Reputation: 13371

use this function :

 function setEqualHeight(columns){
      var tallestcolumn = 0;
      columns.each(function(){
           currentHeight = $(this).height();
           if(currentHeight > tallestcolumn){
                tallestcolumn  = currentHeight;
           }
      });
      if (tallestcolumn <= 1000) {
           columns.css("min-height",(tallestcolumn + 4)+"px");
      }
 }
 $(document).ready(function() {
     setEqualHeight($("#main-content-bottom-bg  > div"));
 });

Upvotes: 1

Darren Griffith
Darren Griffith

Reputation: 3460

Almost... try:

columns.css('min-height', (tallestcolumn + 4) + 'px');

Similar to: jQuery - Set min-height of div

Upvotes: 1

MindTailor
MindTailor

Reputation: 2384

Try this instead :

columns.css('min-height',(tallestcolumn + 4)+'px');

Upvotes: 0

Related Questions