看起來你可以做到這一點 -
var content = $(".content");
// Cache the height in variables, no need to access DOM again and again
var screenHeight = $(window).height();
var contentHeight = content.height();
if(contentHeight>windowHeight-100){
content.css("overflow","auto"); // Note - this will change it for the current instance of the page and NOT in your CSS file
content.css("max-height",(windowHeight-100) + "px");
}
您還可以在結合上述兩個CSS屬性一個單獨的陳述(單獨寫作解釋) -
content.css({"max-height":(windowHeight-100)+"px","overflow":"auto"});
[This](http://stackoverflow.com/questions/838137/jquery-change-height-based-on-browser-size-resize)可能會幫助你交配... –
你遇到的任何錯誤? – Vandesh
沒有錯誤。 例如我的屏幕尺寸是924px,我的內容看起來更高,並且不在屏幕上,但是它只有608px的高度 –