How to prevent fixed button from overlapping footer area and stop the button on top of where the footer is located

前端 未结 3 1080
我寻月下人不归
我寻月下人不归 2021-01-06 18:47

I am trying to create a button that is fixed on the lower-left side of the screen. I tried to setup in JSFiddle to recreate what I\'m trying to do.

Here is my HTML:<

3条回答
  •  说谎
    说谎 (楼主)
    2021-01-06 19:09

    Updated now so that it sticks above footer.

    Hope this is what you meant The jQuery:

    $(window).scroll(function() {
       if($(window).scrollTop() + $(window).height() > $(document).height() - 200) {
           $('#button').addClass('fixed_button');
       }else{
           $('#button').removeClass('fixed_button');
       }
    });
    

    CSS:

    .fixed_button{
        position:absolute !important;
        margin-top:1900px;
        bottom: auto !important;
    }
    

提交回复
热议问题