asp.net - div max-height set dynamically using javascript -


i have web app using master page , content pages (see attached image). need set max-width of 1 div in content page dynamically accordint browser window size (so whole app stays on page, without scrolling). couldn't find sloution (or couldn't replicate results) using html , css. i'm thinking using javascript. problem is, never used it, have no clue how it. i'd appriciate if took couple of minutes , write function it. see it, should take difference in height between bottom edge of header , top edge of footer , subtract height values of searchbar , button bar.

enter image description here

edit: maxedison providing code. but, how use it? :d i'm total noob. have problem, since use masterpage , content pages. put code?

edit 2 - answer:

i looked little further how use jquery, , searched here more, , found solution. next time start developing application, i'll use jquery bottoms up...it simplifies things much. :)

so solution: it's similar maxedison suggested, changed so, set height css , added fixed value deduct window.height.

<script type='text/javascript'>     $(function () {         $('.mystyle').css({ 'height': (($(window).height()) - 350) + 'px' });          $(window).resize(function () {             $('.mystyle').css({ 'height': (($(window).height()) - 350) + 'px' });         });     }); </script> 

using jquery, like:

function resetheight(){     var newheight = $(window).height() - $('.header').outerheight() - $('.searchbar').outerheight() - $('.buttons').outerheight() - $('.footer').outerheight();     $('.content').height(newheight); }  $(function(){     newheight();      $(window).resize(function(){         resetheight();     }); }); 

Comments

Popular posts from this blog

php - How to build a web site which gives a sub-domain dynamically to every registered user? -

android - View with visibility state GONE taking up space on screen -