0

I would like a flex-element with a min-height of 100%. There is a child element always at the bottom. If the content in the first flex child is longer than the screen the site should be normal scrollable.

Here is a pen I made.

Why is it working with height but not min-height?

height: 100%; // works

min-height: 100%; // doesn't works
Paulie_D
  • 107,962
  • 13
  • 142
  • 161
Ranuss
  • 1
  • 1
  • 1

2 Answers2

1

As answered here: CSS Height working but min-height doesn't work

Height can be inherited from positioned parents but not when these have a min-height property.

Which means that .flexbox doesn't inherit height from wrapper because .wrapper has min-height set. When you set height to .wrapper, .flebox and with it .grower can figure out what 100% actually means, and then they grow to fit the screen.

Note: I would say position part of the linked answer is not correct, but the quoted part is.

Sebastijan Dumančić
  • 1,165
  • 1
  • 11
  • 20
0

min-height : Height of the element or css class in question should not be less than specified value, even if height is less that specified value of min-height. It does not specify what the height is going to be, it specifies that it cannot be smaller than its value.

So, if height is 200px, max-height is 230px, min-height is 250px, height of the page component will be 250px. Between height and max-height, max-height can override height.

So, if I change your wrapper class to as shown below, it's height will remain 80%.

.wrapper {
  background-color: pink;
  min-height: 80%;
  height:50px;
}
Amit Kumar Singh
  • 4,393
  • 2
  • 9
  • 22