Reputation: 33
here is my jQuery code, i want to give the div#topImgs height relative to the window height, how it works ?
$("#topImgs").css("height", function(){
$( window ).height();
});
Upvotes: 1
Views: 27
Reputation: 240938
It looks like you need to return the height of the window:
$("#topImgs").css("height", function () {
return $(window).height(); /* Some calculation here.. */
});
$("#topImgs").css("height", $(window).height());
You may not actually need jQuery for this, though. In supported browsers, you can use viewport-relative units, vh
:
#topImgs {
height: 100vh;
}
Upvotes: 1