Set Bootstrap navbar transparency on scroll

后端 未结 3 1503
挽巷
挽巷 2020-12-05 05:58

I use a secondary fille called custom.css to overwrite the bootstrap code and I would like to know how to create a code that is activating only when the visitor of my site i

3条回答
  •  甜味超标
    2020-12-05 06:19

    To avoid the performance hit of using the scroll, load and resize events, you can now use the Intersection Observer API.

    It will allow you to detect if the content on your page has been scrolled, and set the nav bar transparency accordingly (by adding or removing a class).

    Have a look at this answer for more details.

提交回复
热议问题