使用jQuery更改div宽度 [英] Change div width live with jQuery
本文介绍了使用jQuery更改div宽度的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
是否可以使用jQuery更改 div
的宽度?如果是,如何?
Is it possible to change a div
's width live with jQuery? And if it is, how?
我想要的是根据浏览器的窗口宽度实时更改其宽度,所以如果/当用户更改浏览器窗口, div
的尺寸也会实时更改。
What I want is to change its width depending on the browser's window width in real time, so if/when the user changes the browser window, the div
's dimensions are changed as well in realtime.
推荐答案
$( window ).bind("resize", function(){
// Change the width of the div
$("#yourdiv").width( 600 );
});
如果你想要一个DIV宽度作为屏幕的百分比,只需使用CSS width:80%;
。
If you want a DIV width as percentage of the screen, just use CSS width : 80%;
.
这篇关于使用jQuery更改div宽度的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文