2012-02-04 16 views

cevap

73

İşte büyük dolgu ve eşit derecede büyük negatif ekleyerek dayalı bir duyarlı CSS çözüm Her sütuna marj yapın, ardından tüm satırı gizli bir taşma ile bir sınıfa sarın. http://jsfiddle.net/panchroma/4Pyhj/

: Eğer eşit yükseklik kuyu veya köşeleri yuvarlatılmış eşit yükseklik sütunları gerekiyorsa

.col{ 
    margin-bottom: -99999px; 
    padding-bottom: 99999px; 
    background-color:#ffc; 
} 

.col-wrap{ 
    overflow: hidden; 
} 

Bunu bir soruya yanıt olarak düzenleyin

jsFiddle

çalışan görebilirsiniz burada varyasyonu olan

Edit

+1

Bir dezavantaj, arka plan çekildi ve taşma nedeniyle jsut gizlendi. Başka bir şey yaparsanız, o zaman statik bir renk varsa alt sınırı görmezsiniz. Her sütunda iyi ara ile birlikte deneyin. –

+0

@ s093294, bir jsFiddle başlatmak istiyorsanız, şanslı olabilirsiniz ve özel durumunuzda bir çözüm bulabiliriz. –

+0

http://jsfiddle.net/teFYS/109/ sadece sorunumu açıklamak için buradan bir tane güncellendi. –

16

deneyin şey: Birden elemanları seçildiğinde

$('.well').css({ 
    'height': $('.well').height() 
}); 

jQuerys height() yöntem en yüksek değeri döndürür. http://jsfiddle.net/4HxVT/

+1

Bunu denedim ancak 'height()' aslında ilk öğeyi döndürür: "Açıklama: Eşleşen öğeler kümesindeki ilk öğe için geçerli hesaplanmış yüksekliği alın." http://jsfiddle.net/p4ekd/ –

4

zaten verilen cevaplar üzerine Genişleyen, sadece bu jquery ve underscore kullanarak çözdük. Aşağıdaki snippet uzun bir göründüğü yerleri ne olursa olsun, belirli bir satırda görünmesi benim kuyuları ve uyarıların yüksekliğini eşitleyen:

$('.well, .alert').height(function() { 
    var h = _.max($(this).closest('.row').find('.well, .alert'), function (elem, index, list) { 
     return $(elem).height(); 
    }); 
    return $(h).height(); 
}); 
1

Özel bir jQuery max eklentisi ile bu çözülebilir:

$.fn.max = function(selector) { 
    return Math.max.apply(null, this.map(function(index, el) { return selector.apply(el); }).get()); 
} 
bir soruya yanıt olarak

, burada sadece Bootstap ızgara sınıf adını güncellemek, Bootstrap 3, aynı prensipte aynı tekniktir

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

    $(this).each(function(i, e) { 
    var height = $(e).height(); 
    max = height > max ? height : max; 
    }); 

    $(this).height(max); 
}; 

$('.match-height').matchHeight(); 
0
:

Burada içerik kutu zaman iç sütun elemanı, içerik konteyner sütun içerir sarıcı olupYukarıdaki tüm çözümler, güzel önyükleme butonları ekleyene kadar çalışır! Düğmeleri nasıl konumlandırırsın diye düşündüm (evet, benim problemim buydu).

Ben düğmeleri hizaya olmadığı halde CSS ile çalışır bu var frigging biraz, sonra How might I force a floating DIV to match the height of another floating DIV?

Jquery cevap CSS kombine ve jQuery

hissedin ile gayet

$.fn.equalHeights = function (px) { 
    $(this).each(function() { 
     var currentTallest = 0; 
     $(this).children().each(function (i) { 
      if ($(this).height() > currentTallest) { 
       currentTallest = $(this).height(); 
      } 
     }); 
     if (!px && Number.prototype.pxToEm) { 
      currentTallest = currentTallest.pxToEm(); //use ems unless px is specified 
     } 
     // for ie6, set height since min-height isn't supported 
     if ($.browser.msie && $.browser.version == 6.0) { 
      $(this).children().css({ 
       'height': currentTallest 
      }); 
     } 
     $(this).children().css({ 
      'min-height': currentTallest + 40 // THIS IS A FRIG - works for jquery but doesn't help CSS only 
     }); 
    }); 
    return this; 
}; 

$(document).ready(function() { 
    var btnstyle = { 
    position : 'absolute', 
    bottom : '5px', 
    left : '10px' 
    }; 
    $('.btn').css(btnstyle); 
    var colstyle = { 
    marginBottom : '0px', 
    paddingBottom : '0px', 
    backgroundColor : '#fbf' 
    }; 
    $('.col').css(colstyle);  
    $('.row-fluid').equalHeights(); 
}); 

CSS

: bit :)

jQuery CSS düğme hattı düzeltmek için ücretsiz

.col { 
    margin-bottom: -99999px; 
    padding-bottom: 99999px; 
    background-color:#ffb; 
    position:relative; 
} 
.col-wrap { 
    overflow: hidden; 
} 

.btn{ 
    margin-left:10px ; 
} 
p:last-child { 
margin-bottom:20px ; 
} 

jsfiddle - http://jsfiddle.net/brianlmerritt/k8Bkm/ İşte

0

2 sütun (sadece fazla koşul eklemek basittir fazla sütunlara bu uyum) ile benim çözümdür. Tüm öğelerin doğru yüksekliğine sahip olması için yükleme olayında çalıştırın.

$(window).on('load', function() { 
    var left = $('.left'); 
    var leftHeight = left.height(); 
    var right = $('.right'); 
    var rightHeight = right.height(); 

    // Width like mobile, the height calculation is not needed 
    if ($(window).width() <= 751) 
    { 
     if (leftHeight > rightHeight) { 
      right.css({ 
       'height': 'auto' 
      }); 
     } 
     else { 
      left.css({ 
       'height': 'auto' 
      }); 
     } 

     return; 
    } 

    if (leftHeight > rightHeight) { 
     right.css({ 
      'height': leftHeight 
     }); 
    } 
    else { 
     left.css({ 
      'height': rightHeight 
     }); 
    } 
}); 

<div class="row"> 
    <div class="span4 left"></div> 
    <div class="span8 right"></div> 
</div> 
İlgili konular