I'm trying to make my body element the height of the viewport, but expand if its content exceeds its height. I originally used min-height: 100vh to accomplish this.
However, as stated in this answer, an element with a percentage height will not work correctly inside my body because it uses min-height.
My next idea was to use the max function alongside min-content on my body:
body {
height: max(100vh, min-content);
}
However this does not work. In Chrome devtools I get the following warning:
Invalid property value
Is there any solution to this problem?
More details
- There will be one element inside
body. - This element should be able to use percentage-based height values or
auto. - The height of the body should expand if the content inside does not fit.
- If the content inside
bodydoes fit, then any percentage-based height values would be based on the viewport height.
