这里是我的jQuery代码,我想给出相对于窗口高度的div #topImgs高度,它是如何工作的?
$("#topImgs").css("height", function(){
$( window ).height();
});
答案 0 :(得分:0)
看起来你需要返回窗口的高度:
$("#topImgs").css("height", function () {
return $(window).height(); /* Some calculation here.. */
});
$("#topImgs").css("height", $(window).height());
你可能实际上并不需要jQuery。在supported browsers中,您可以使用viewport-relative units, vh
:
#topImgs {
height: 100vh;
}