I am trying to position footer at the bottom of the page, but not sticky. I have a problem when there is not enough content to cover the screen height, then the footer is not at the bottom. I have tried to set it up in CSS like this:
body {
position: relative;
margin: 0;
padding-bottom: 8rem;
min-height: 100%;
overflow-x: hidden;
}
footer {
position: absolute;
display: flex;
align-items: center;
height: 4rem;
right: 0;
bottom: 0;
left: 0;
background-color: $gray;
}
With this footer is only at the bottom of the page when there is enough content on it. But, when there is not enough content then it is above the bottom. Here is the example:
Here is the fiddle.
When I add to the css file, like suggested in the answers:
html, body {
height: 100%;
}
Then, I have a problem with pages where there is alot of content, then the footer is at the bottom on page load, but when I start to scroll down, it goes up with the content, like shown in the image: