Home > Web Front-end > JS Tutorial > JavaScript method to set body height to browser height_javascript skills

JavaScript method to set body height to browser height_javascript skills

WBOY
Release: 2016-05-16 16:15:07
Original
1509 people have browsed it

The example in this article describes how to set the body height to the browser height using JavaScript. Share it with everyone for your reference. The specific implementation method is as follows:

For the height of a div node to be implemented as a percentage, its parent node must have a certain height. Therefore, if the child node under the body node wants to use a percentage to determine the height, it must give a height to the body.

Copy code The code is as follows:
<script> <br> ​ ​ ​ setTimeout(function(){  <br>                   document.getElementsByTagName('body')[0].style.height = window.innerHeight 'px'; <br>          },20);                                        </script>
I hope this article will be helpful to everyone’s JavaScript programming design.

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template