【发布时间】:2013-11-20 03:05:07
【问题描述】:
.content-block 类内容动态文本,因此每个 div 块的高度不同。使用 javascript max height of div find 适用于其他 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;
}
【问题讨论】:
-
你可以使用
display: table-cell来做同样的事情。这里不需要javascript。
标签: javascript jquery css twitter-bootstrap cross-browser