B
B
bshowyt2020-04-23 10:34:35
css
bshowyt, 2020-04-23 10:34:35

Why doesn't the body stretch to the full height of the content?

I can’t understand why in this example the body is not stretched to the full height of the content, but is cut off, dragging the sticky header along with it. Please tell me why this is happening. I need the body to stretch to the full height of the screen, and if there is more content, then stretch to the height of the content.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
P
Pavel Lovtsevich, 2020-04-23
@bshowyt

Because the body is set to 100% html, and it is also set to 100%, which are counted from the viewport. The solution is:

html {
  height: 100%;
}
body {
  min-height: 100%;
}

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question