March 12, 2012
Set DIV height so that it reaches the bottom of the viewport
Question by Blacksad
How to set the height of this DIV so that it reaches the bottom of the viewport ? The DIV cannot be absolutely positioned ; it’s in the flow.
<html>
<body>
Hello world...
<div>xxx</div>
</body>
</html>
If there is a CSS solution (which I doubt), it’s great but using JS/jQuery is fine. CSS3 is fine too.
Answer by paislee
Answer by Starx
Use $(window).height()
to get the actual height of the element
$("div").height($(window).height())