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

How to stretch an element to window height

王林
王林forward
2020-07-29 17:25:012218browse

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%;
}

(Recommended video tutorial: css video tutorial )

Then apply 100% to the height of any element.

div {
    height: 100%;
}

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!

Statement:
This article is reproduced at:juejin.im. If there is any infringement, please contact admin@php.cn delete