我有3個不同數量的內容的div。我希望divs因爲背景而在高處相匹配。我的問題是如果可能的話,如何用純html/css而不使用jQuery/Javascript來實現。html列適合內容,但並排高度(沒有jQuery)
小時,每個div變成12列,因此它們的高度符合內容。中等時,綠色和藍色的高度相同。大時,灰色框與藍色和綠色div的高度相匹配。
https://jsfiddle.net/Ljzr2krv/
.col-1 {
background-color: blue;
}
.col-2 {
background-color: green;
}
.col-3 {
background-color: grey;
}
<link href="https://cdnjs.cloudflare.com/ajax/libs/foundation/6.3.1/css/foundation.min.css" rel="stylesheet"/>
<div class="row collapse">
<div class="large-3 small-12 columns">
<div class="row collapse">
<div class="small-12 medium-6 large-12 columns col-1">
The quick brown fox jumps over the lazy dog. The quick brown fox jumps over the lazy dog. The quick brown fox jumps over the lazy dog. The quick brown fox jumps over the lazy dog.
</div>
<div class="small-12 medium-6 large-12 columns col-2">
The quick brown fox jumps over the lazy dog. The quick brown fox jumps over the lazy dog. The quick brown fox jumps over the lazy dog. The quick brown fox jumps over the lazy dog. The quick brown fox jumps over the lazy dog.
</div>
</div>
</div>
<div class="large-9 small-12 columns col-3">
The quick brown fox jumps over the lazy dog. The quick brown fox jumps over the lazy dog. The quick brown fox jumps over the lazy dog. The quick brown fox jumps over the lazy dog. The quick brown fox jumps over the lazy dog. The quick brown fox jumps over the lazy dog. The quick brown fox jumps over the lazy dog. The quick brown fox jumps over the lazy dog. The quick brown fox jumps over the lazy dog. The quick brown fox jumps over the lazy dog. The quick brown fox jumps over the lazy dog. The quick brown fox jumps over the lazy dog. The quick brown fox jumps over the lazy dog. The quick brown fox jumps over the lazy dog. The quick brown fox jumps over the lazy dog. The quick brown fox jumps over the lazy dog. The quick brown fox jumps over the lazy dog. The quick brown fox jumps over the lazy dog. The quick brown fox jumps over the lazy dog. The quick brown fox jumps over the lazy dog.
</div>
</div>
目前,爲了實現這一目標,我一直在使用jQuery搶的div自然的高度,並分配的較大高度取決於窗口大小。每次調整窗口大小時都會調用它。
我希望能夠實現div的這種安排,同時允許div的高度像上圖中一樣對齊的html/css解決方案。
如果你想顯示影像中的邊距和補你將不得不改變你的標記。 –