One crucial issue lies in misusing the position property.
The position property is particularly useful when dealing with boxes.
In your styles.css
.App {
font-family: sans-serif;
min-height: 100%;
position: relative;
}
.footer {
position: absolute;
min-height: 2rem;
width: 100%;
text-align: center;
bottom: 0;
}
.flex {
display: flex;
flex-direction: column;
justify-content: space-between;
width: 100%;
}
Revise it to:
.App {
font-family: sans-serif;
min-height: 100vh;
}
.footer {
min-height: 2vh;
width: 100%;
text-align: center;
}
.flex {
display: flex;
flex-direction: column;
justify-content: space-between;
width: 100%;
min-height: 90vh;
}
Explanation:
The concept behind this adjustment is to ensure the footer consistently maintains a specific portion of the viewport. By dividing the viewport into ratios, we secure this consistent positioning regardless of content changes.
In this case, the div with the className App has a min-height of 100vh, signifying that it occupies at least 100 equal portions of the viewport. Within App, both flex and the footer are allocated minimum slice requirements - flex receives 90 pieces and the footer gets 2. This guarantees the footer remains fixed at the bottom always.
See the updated outcome here