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
Post a Comment