Click here to Skip to main content
15,891,136 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
Need to resize div on window resize, basically I want to change between two fixed width: 600px and 1000px. So if 1000px do not fit the screen - change to 600px.
NOTE: it is important to keep width fixed.

The code I was able to find/edit in the internet:
XML
<script>
$(window).resize(function ()
{
    if($(window).width() > 1020){
        $('#container').css('width', '1000px');
    else
        $('#container').css('width', '600px');
});
</script>

But it does not working.
Posted
Comments
Matej Hlatky 11-Jul-13 2:43am    
Have you ever heard of CSS3 Media Queries?

1 solution

Thanks Matej Hlatky, it helped a lot.)))
Not sure if I did it right, but here is the code:
CSS
#container {
    /*css styles*/
    width: 600px;
}
@media (min-width: 1020px) {
#container {
    width: 1000px;
}
}

It overwrites the first width.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900