Change div width live with jQuery

前端 未结 5 1191
闹比i
闹比i 2021-01-01 13:54

Is it possible to change a div\'s width live with jQuery? And if it is, how?

What I want is to change its width depending on the browser\'s window width

5条回答
  •  攒了一身酷
    2021-01-01 14:53

    You can use, which will be triggered when the window resizes.

    $( window ).bind("resize", function(){
        // Change the width of the div
        $("#yourdiv").width( 600 );
    });
    

    If you want a DIV width as percentage of the screen, just use CSS width : 80%;.

提交回复
热议问题