views:

234

answers:

2

I am using this script from snipplr, How would I set it so the container div is 100px less than the newWindowHeight height, like -100 or something.

<script type="text/javascript" charset="utf-8">
$(document).ready(function(){

//If the User resizes the window, adjust the #container height
$(window).bind("resize", resizeWindow);
function resizeWindow( e ) {
    var newWindowHeight = $(window).height();
    $("#container").css("max-height", newWindowHeight );
}

});         
</script>
+7  A: 

The script you found over-complicated the issue. The following worked for me:

$(function(){

  $(window).resize(function(){
    $("#container").css("max-height", $(this).height() - 100);
  });

});
Jonathan Sampson
A: 
$("#container").css({'height': ($(window).height() - 100) + "px"});
sberry2A
You don't need to include "px" - it's assumed.
Jonathan Sampson