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
1. Download the 64-bit zip file from the official...
1. Use contrasting colours. The contrast here ref...
In this article, we will use the libudev library ...
What is a Viewport Mobile browsers place web page...
Logpoint-based replication 1. Create a dedicated ...
Table of contents 1. MySQL trigger creation: 1. M...
Note: This article is about the basic knowledge p...
Table of contents Preface 1. Error log 2. Binary ...
Table of contents 1. Use in components 2. Option ...
This database query statement is one of 50 databa...
Preface This article mainly introduces the relati...
Table of contents 1. Modify by binding the style ...
The database installation tutorial of MySQL-8.0.2...
1. Create a repository in the specified directory...
Table of contents 1. typeof 2. instanceof 3. Cons...