You can take a look at the event $.resize (http://api.jquery.com/resize/) jquery
Here’s an example I did for you to see how it works
Jquery
$(function(){
$(window).resize(function(){
var winW = $(window).width();
var winH = $(window).height();
var divResize = $(".divResize");
if(winW < 500)
divResize.css('width', winW);
if(winH < 500)
divResize.css('height', winH);
});
});
HTML
<div class="divResize"></div>
CSS
body, html {
height:100%;
min-height:100%;
padding:0;
}
.divResize {
background:#000;
width:100%;
height:100%;
max-width:500px;
max-height:500px;
}
In this example when the useful area of the browser is less than 500px it will give a resize according to the screen size.
DEMO
Should this yours div be a background and occupy 100% (both width and height), there are some tips you may be using.
DEMO
Do you want to make a recursive layout right? Have you tried bootstrap ? Com makes it much easier to do these things with his classes.
– Érik Thiago
Use a grids system such as 960.Gs or twitter bootstrap...
– Marcelo Aymone
The site is already ready :) I was only asked to make this div decrease after I finished. I mean, I will not use Bootstrap. I’m looking for something in Jquery, only I’m missing the necessary knowledge now.
– Felipe Viero Goulart
You can do with
heightrelative, via CSS itself:– Beterraba
@Beets how? I was trying
function resizeFundo1(){
 var telaAltura = $(window).height();
 $('.fundo1img').css({'height': telaAltura + 'px'});
}but it did not happen– Felipe Viero Goulart
If you set your div with relative height (
height: 90%, for example), she will occupy 90% of the height set on her father.– Beterraba
@Beet but that’s not what I need. I need that
divdecrease as user moves screen size.– Felipe Viero Goulart
Behold this fiddle.
– Beterraba
Thanks to @Beterraba
– Felipe Viero Goulart