Reputation: 3783
I'm trying to resize the main content div #inhalt of my website so that it always fills all the space available. Basically I do this by setting a height of total usable height - top position of #inhalt (pixels from top) - padding etc.. This is my javascript/jQuery code:
$(document).ready(function(){
$("#inhalt").height($("#zentriert").height() - $("#inhalt").position().top - 48);
$(window).resize(function() {
$("#inhalt").height($("#zentriert").height() - $("#inhalt").position().top - 48);
});
});
This works fine when I resize the window so that it gets bigger. It doesn't, however, when I make it smaller.
Does anybody have an idea why and what I could do?
Upvotes: 0
Views: 1855
Reputation: 69915
It does work fine for me. I have used it at plenty of places. You can check this by having a log message inside resize
handler.
$(window).resize(function() {
console.log('window resized');
$("#inhalt").height($("#zentriert").height() - $("#inhalt").position().top - 48);
});
Upvotes: 1