网址:http://negativgraffiti.hu/uj/
如果您从一个页面跳到另一个页面,每个页面都有不同的高度,但它们都在一个div中,只是它们并不总是可见的。
每次我都会将父div的大小调整为当前页面的高度(不是完整的代码,只是一个示例):
var magassag = jQuery("#post-5");
var egymagas = jQuery(".elsofo").height();
if (i == 1) {
magassag.animate({
height: egymagas
}, 100 );
}它工作得很好,但当我在平板电脑/移动设备上测试它时,当我改变方向时,它的高度就会变得很糟糕,我不知道为什么。
发布于 2015-05-01 03:14:25
使用$(window).on('resize', fn)检测窗口大小调整。
$(window).on('resize', function() {
// re-animate the height for the current page
});虽然这对于调整平板电脑的大小很有效,但对于用鼠标调整窗口大小的桌面用户来说,效率会非常低。出于这个原因,throttle调整大小回调是很好的。
// Use `throttle` from any of the various throttle libraries available.
$(window).on('resize', throttle(function() {
// re-animate the height for the current page
}));https://stackoverflow.com/questions/29975646
复制相似问题