Note that there are some explanatory texts on larger screens.

plurals
  1. POdiv max-height set dynamically using javascript
    primarykey
    data
    text
    <p>I have a web app using master page and content pages (see the attached image). I need to set max-width of one div in content page dynamically accordint to the browser window size (so that the whole app stays on the page, without scrolling). I couldn't find the sloution (or couldn't replicate the results) using just html and CSS. So I'm thinking to do it using javascript. But the problem is, I NEVER used it, so I really have no clue how to do it. I'd really appriciate if someone took a couple of minutes and write the function that will do it. As I see it, I should take difference in height between bottom edge of the header and top edge of the footer and subtract height values of searchbar and button bar.</p> <p><img src="https://i.stack.imgur.com/fIAlu.png" alt="enter image description here"></p> <p>EDIT: Thanks to maxedison for providing that code. But, how do I use it? :D I'm a total noob. I have a problem, since I use masterpage and content pages. Where do I put that code? </p> <p><strong>EDIT 2 - THE ANSWER:</strong></p> <p>I looked a little further into how to use jQuery, and searched here some more, and I found a solution. Next time I start developing an application, I'll use jQuery from the bottoms up...It just simplifies some things so much. :) </p> <p>So for the solution: It's similar to what maxedison suggested, but I changed it so, that I set height with CSS and I just added a fixed value to deduct from window.height.</p> <pre><code>&lt;script type='text/javascript'&gt; $(function () { $('.myStyle').css({ 'height': (($(window).height()) - 350) + 'px' }); $(window).resize(function () { $('.myStyle').css({ 'height': (($(window).height()) - 350) + 'px' }); }); }); &lt;/script&gt; </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload