Jquery: 100% Height (html, body)


/ Published in: jQuery
Save to your folder(s)

Declare html, body {height: 100%} in your css. Subtract all divs with a given height, such as a header, navigation and a footer. Like this: "#header" - "#navigation" - "#footer" + "px". Then add the element you need at 100% height.


Copy this code and paste it in your HTML
  1. $(document).ready(sizeContent);
  2. $(window).resize(sizeContent);
  3. function sizeContent() {
  4. var newHeight = $("html").height() - $("#subtract-all-other-divs").height() + "px";
  5. $("#the-div-you-need-100%-height").css("height", newHeight);
  6. }

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.