我如何使用 jQuery 做到这一点:http://jsfiddle.net/tdskate/C4nAG/
我需要一个 div,它可以根据剩余的可用垂直空间自动调整高度。
我尝试用 $('body > *').height()
计算它,然后从中减去元素的高度...但是当某些元素有顶部或底部边距。
此外,它需要在调整浏览器窗口大小时调整大小...
最佳答案
这应该有效:
$(function() {
$(window).resize(function() {
var other_element_heights = 0;
$('body').children().each(function() {
other_element_heights += $(this).outerHeight(true);
});
other_element_heights -= $('.auto-height').height();
$('.auto-height').height($(window).height() - other_element_heights);
}).resize();
});
关于jquery - 仅使用 jQuery 的 CSS3 垂直框 flex,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7959483/