开发者

Change body width using javascript

开发者 https://www.devze.com 2023-03-18 17:05 出处:网络
I just came to know that we can find out the screen resolution of our users using screen.width and screen.height etc. But is there a开发者_开发知识库ny way to have a variable body width. I mean can i

I just came to know that we can find out the screen resolution of our users using screen.width and screen.height etc. But is there a开发者_开发知识库ny way to have a variable body width. I mean can i set the body width property using jquery or javascript. This is gonna change with the resolution of every user so that my site seems perfect in all of them...

Can anyone help me in having code to set the width(CSS) of my page according to the value obtained through Jscript above.

Thanks


You can set the body with JavaScript...

document.body.style.width = '700px';

...or if you are using jQuery...

$('body').css('width', '700px');


You can use jquery and do it through .css

$('body').css('width', '1000px');

css() documentation.

0

精彩评论

暂无评论...
验证码 换一张
取 消