このマークアップは機能するはずだと思いましたが、何か間違ったことをしているに違いありません。同じ高さにしたい2つのdivがあり、ウィンドウのサイズが変更されたときに動的にサイズを変更します。ボックス内のテキストが折り返されると、ボックスの1つが高くなります。
編集:2つのdivが並んでいるので、短い方のdivのサイズを高い方のdivと同じ高さにしたいと思います。ユーザーが画面が小さいデバイスを使用している場合、またはウィンドウのサイズを小さくする場合は、のテキストが1つのボックスで折り返されます。ユーザーがウィンドウのサイズをどのように変更しても、両方を同じ高さにしたいと思います。
JS
$(document).ready(function () {
$('div.subFeaturedContainer > section').each(function() {
var $sameHeightChildren = $(this).find('.subFeatured');
var maxHeight = 0;
$sameHeightChildren.each(function() {
maxHeight = Math.max(maxHeight, $(this).outerHeight());
});
$sameHeightChildren.css({ height: maxHeight + 'px' });
});
});
HTML
<div class="subFeaturedContainer">
<section class="subFeatured">
<h2>Header</h2>
<a href="#">Nam vel risus mauris, id lacinia nulla</a>
</section>
<section class="subFeatured">
<h2>Header</h2>
<a href="#">Donec tincidunt tellus ac dolor tristique blandit. Nam vel iaculis lorem.</a>
</section>
</div>
CSS
.subFeatured {
width: 43.5%;
float: left;
background: rgba(0, 0, 0, 0.7);
border-top: 1px solid #b1bdbe;
padding: 2% 3% 2% 3%;
}
.subFeatured:nth-child(even) {
float: right;
}