javascript - Change Div Width Along on load and resize -


i wrote code change width , height of wrapper box based on available space on screen. when open page, div loads when resize size of div not change.

var width = (($(window).width()) - 100); var height = (($(window).height()) - 100);  $(window).ready(function() {     $("#wrapper").width(width);     $("#wrapper").height(height); });  $(window).resize(function(){     $("#wrapper").width(width);     $("#wrapper").height(height); }); 
<!doctype html> <html> <head>     <meta charset="utf-8">     <title>xyz</title> </head> <body>     <div id="wrapper">         asd     </div> </body> </html> 

you need recalculate dimension.

$( window ).resize(function(){     width = (($(window).width())-100);     height = (($(window).height())-100);     $("#wrapper").width( width );     $("#wrapper").height( height ); }); 

Comments

Popular posts from this blog

Email notification in google apps script -

c++ - Difference between pre and post decrement in recursive function argument -

javascript - IE11 incompatibility with jQuery's 'readonly'? -