问题
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 any 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
回答1:
You can set the body with JavaScript...
document.body.style.width = '700px';
...or if you are using jQuery...
$('body').css('width', '700px');
回答2:
You can use jquery and do it through .css
$('body').css('width', '1000px');
css() documentation.
来源:https://stackoverflow.com/questions/6620029/change-body-width-using-javascript