1. Original Definition First define in css: body, html { width: 300px; height: 300px; } 2. JS operation, taking width modification as an example// Get the body and html node styles (mainly html here, it is not clear how to get it at first) let bodyStyle = document.body.style let htmlStyle = document.getElementsByTagName('html')[0].style // Get the width of the browser. Width can also be set to any value. let width = document.documentElement.clientWidth || document.body.clientWidth // Reset body width bodyStyle.width = `${width}px` // Reset html width htmlStyle.width = `${width}px` // Or other style modifications, such as: htmlStyle['min-width'] = `${width}px` 3. Effect: Width has been modifiedThis is the end of this article about how to modify the style of HTML body in JS. For more information about how to modify the style of HTML body in JS, please search for previous articles on 123WORDPRESS.COM or continue to browse the following related articles. I hope you will support 123WORDPRESS.COM in the future! You may also be interested in:
|
<<: How to replace all tags in html text
>>: Use tomcat to deploy SpringBoot war package in centos environment
nginx Overview nginx is a free, open source, high...
1. Why set maxPostSize? The tomcat container has ...
This article shares the specific code of Vue to r...
Table of contents Overview first step Step 2 Why ...
Table of contents 1. Use scripts to encrypt TLS f...
1. Introduction Today a colleague asked me how to...
The knowledge points summarized below are all fre...
Ubuntu Server 16.04 MySQL 8.0 installation and co...
Table of contents Linux environment variables and...
Problem Reproduction When using HTML for editing,...
There is an interview question that requires: a th...
Why is it that when the input tag type is file an...
Simply put, delayed replication is to set a fixed...
1. When inserting, updating, or removing DOM elem...
Table of contents Overview The history of CPU-bou...