I want to customize the menu with jQuery to follow the scroll.

Asked 2 years ago, Updated 2 years ago, 69 views

"I would like to implement a menu that remains in a fixed position on the page even if I scroll, such as ""sponsor link"" at the bottom of the right menu of the site below."

http://www.akb48matomemory.com/archives/1017688632.html

However, I would like to do the following, but would it be possible to implement it like this?

  • Fixed top when scrolling down
  • Fixed to the bottom of the window when scrolling from bottom to top

Let me borrow your wisdom.
Thank you for your cooperation.

javascript css jquery

2022-09-30 20:29

1 Answers

After comparing the current sscrollTop と with the previous sscrollTop を in the callback of the onscroll event and finding the direction, you can do it with the CSS position: fixed and top:0 or bottom:0

You can calculate "scrollTop" in any browser as shown below.

window.pageYOffset||( document.documentElement& document.documentElement.scrollTop)|| document.body.scrollTop


2022-09-30 20:29

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.