I've been working on creating a footer for my Angular application and here's the code for it:
// HTML
<footer class="footer">
// code for footer
</footer>
// LESS
.footer {
position: absolute;
bottom: 0;
width: 100%;
height: 200px;
background-color: #ffffff;
}
.content {
min-height: 500px;
}
// Application's layout:
<app-header1></app-header1>
<div class="container content">
<router-outlet></router-outlet>
</div>
<app-footer></app-footer>
Initially, everything was fine with the footer on the homepage. However, when switching to different pages, the footer started behaving oddly. It would jump to the middle of the page and stay there while scrolling. I realized that removing bottom: 0;
made the footer go back to the bottom, but then returning to the homepage caused it to float in between the content and the bottom.
Here are some screenshots to visually represent the issue:
PAGES with bottom: 0;
https://i.stack.imgur.com/gNtdV.png
https://i.stack.imgur.com/vyjDp.png
PAGES with NO bottom: 0;
https://i.stack.imgur.com/fqMzu.png
https://i.stack.imgur.com/5SjjJ.png
PAGE with position: fixed;
https://i.stack.imgur.com/2I9Ex.png