2

How do i modify the below code so that instead of minusing 210 is minuses another div height so that the equation essentially becomes "main-menu = window height - div height"?

$('#main-menu').css({'height':(($(window).height())-210)+'px'});

1 Answer 1

3

Here is the Jsfiddle

Markup like this:

​<div id="main-menu"></div>
<div id="other-div">
    <h1>Sample Content</h1>
    <p>
        foo bar foo bar foo bar foo bar foo bar foo bar foo bar foo bar foo bar 
    </p>
</div>​

Css like this:

​#other-div {
    background: #cdcdcd;
}​

Javascript like this:

$('#main-menu').height($(window).height()-$("#other-div").height());​

As you can see from the script, I call the height function.

1
  • Nah, the height of that div isn't fixed, it's based on the content isnt it.
    – CoreyRS
    Apr 12, 2012 at 19:42

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.