Home > Web Front-end > CSS Tutorial > How to stretch an element to window height

How to stretch an element to window height

王林
Release: 2020-07-29 17:25:01
forward
2249 people have browsed it

How to stretch an element to window height

In specific scenarios, we may want to stretch an element to the height of the window. Adjustment of basic elements can only adjust the size of the container, so to make an element stretch to the height of the window, We need to stretch the top elements: html and body.

(Recommended tutorial: css quick start)

Code implementation:

html, 
body {
    height: 100%;
}
Copy after login

(Recommended video tutorial: css video tutorial )

Then apply 100% to the height of any element.

div {
    height: 100%;
}
Copy after login

The above is the detailed content of How to stretch an element to window height. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:juejin.im
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