Why add "height: 100%;" to html and body

Because if it is not added, the value of the body height is the height reached by all elements on the page.

You can add a background color to the body to see the effect. If the file stream is not very long and does not fill the entire window (no scroll bar is generated), you can see that the background color is only applied to the end of the file stream.

Adding "height:100%;"this style to html specifies the height of the parent element of the body as 100%, and then specifies height: 100%; in the body, which means that the entire window is occupied.

In this way, when the file stream does not fill the window, the background and other effects can be well presented.

Guess you like

Origin www.cnblogs.com/baimeishaoxia/p/12675692.html