.content-block
类内容动态文本,因此每个div块的高度不同 . 使用javascript最大高度div找到适用于其他div的浏览器调整大小所有div将同样高度 . 下面的伪代码工作在大多数浏览器中,但在chrome中,浏览器调整大小小于320x480将无法正常工作 .
<script type="text/javascript">
function getMaxHeight(){
return maxHeight = Math.max.apply(null, $(".content-block").map(function (){
return $(this).height();
}).get());
}
$(window).resize(function(){
$('.content-block').css('height', 'auto');
$('.content-block').css('height', getMaxHeight);
});
$('.content-block').css('height', getMaxHeight);
</script>
<style>
.content-block{
height: auto;
display: block;
}
1 回答
如果您可以将css flexbox用于此目的,则使用JavaScript可能会导致扩展问题 . 这是CSS-Tricks Reference