Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Dynamically resize div based on window size

I'm trying to optimise my website for different resolutions. In the center of the website I have a DIV that currently has a fixed size. I'm trying to make its size (and contents) change according to the size of the browser window. How do I do that? This is my website if you want to take a look at its code: http://www.briefeditions.com

like image 548
Johanna A Avatar asked Jul 13 '12 05:07

Johanna A


1 Answers

If you resize the page the div will resize with it and on load of the page.

$(window).on('load resize', function(){
    $('#div').width($(this).width());
});
like image 152
Adam Merrifield Avatar answered Sep 20 '22 01:09

Adam Merrifield