1

I am having some difficulties with footer css. I want it to stay in the bottom of the page. I don't want it to be visible until i scroll to the bottom of the page.

.footer{
    position: fixed;
    display: block;
    width: 100%;
    height: 80px;
    bottom: 0;
    float: none;
}
Phiter
  • 14,570
  • 14
  • 50
  • 84
Jurgis
  • 231
  • 1
  • 3
  • 9

2 Answers2

1

The problem come from position: fixed;.

"fixed" means that it is fixed on the viewport. So try to remove position: fixed;

CSS : Position property

Charles.C
  • 345
  • 1
  • 3
  • 12
  • This [article](https://css-tricks.com/absolute-relative-fixed-positioining-how-do-they-differ/) might be useful as well. – Phiter Mar 21 '18 at 16:30
  • The problem is, that in case the webpage would have blank space after last component, my footer is simply floating in the air after last component. – Jurgis Mar 21 '18 at 18:04
0
.footer {
    position: absolute;
    display: block;
    width: 100%;
    height: 0;
    bottom: 0;
    float: none;
    transition: height 1s ease-in-out;
}
.footer.active {
    height: 80px;
}

<script type="text/javascript">
    window.onscroll = function(ev) {
        if ((window.innerHeight + window.scrollY) >= document.body.offsetHeight) {
            $(".footer").addClass('active');
        } else {
            $(".footer").removeClass('active');
        }
    };
</script>

<div class="footer">
    ...
</div>
Matt D
  • 387
  • 1
  • 4
  • 18