CSS Change Background Color at Certain Point

后端 未结 4 608
鱼传尺愫
鱼传尺愫 2021-01-27 17:18

I would like the background of the entire site to change from white to black when a certain element comes into view. So when you scroll by the element the background transitions

4条回答
  •  既然无缘
    2021-01-27 17:57

    Your $(window).scroll is correct but i think your code lacks the proper setup to do what you want. Here is a working sample i made from your code to change the color of the background when the block div comes into view when scrolling.

    https://codepen.io/Nasir_T/pen/jmvwEP

    Hope this helps.

提交回复
热议问题