Switch div from fixed to absolute at bottom of browser

前端 未结 5 1936
梦毁少年i
梦毁少年i 2021-01-18 01:51

Im trying to add a footer at the bottom of this content that doesn\'t overlay the content but moves it up.

The only way I can see it working would be something like,

5条回答
  •  陌清茗
    陌清茗 (楼主)
    2021-01-18 02:19

    You should use jQuery to add a class containing the position:fixed value when the scroll position of the page is less than the inline position of the #work div. Once it scrolls past the position, remove the class and have the element fall back in line.

    You can achieve this using the following jQuery methods.. .scrollTop() .offset().top() and $(window).height().

    This tutorial will give you an understanding of what you need to do to achieve the necessary results, you will just have to change the calculation slightly using $(window).height(), $('#footer').height() and a few other changes to get what you desire.

提交回复
热议问题