简体   繁体   English

在滚动中的div内淡入和淡出内容

[英]Fade in&out content inside a div on scroll

I need some content to appear (fade in) and disappear (fade out) inside a div while scrolling down with the BROWSER SCROLLBAR (not a scrollbar inside the div), making it reverse when scrolling up ( in a loop). 我需要一些内容来显示(淡入)和消失(淡出)在div内,同时使用BROWSER SCROLLBAR(而不是div内的滚动条)向下滚动,使其在向上滚动(循环)时反转。

This link shows a video about what I exactly mean: https://youtu.be/6pSIGNe1yWg 该链接显示了有关我的确切意思的视频: https : //youtu.be/6pSIGNe1yWg

It looks pretty simple, but all the examples I have seen on the Internet are related to revealing/hiding content at the top/bottom of the screen. 看起来很简单,但是我在Internet上看到的所有示例都与在屏幕顶部/底部显示/隐藏内容有关。 Others, like news tickers, for example, depend on scrollbars inside the div or buttons to slide up/down the content ( http://logicbox.net/jquery/simplyscroll/vertical.html ) 其他消息,例如新闻动态,则取决于div内的滚动条或向上/向下滑动内容的按钮( http://logicbox.net/jquery/simplyscroll/vertical.html

So, how to reveal/hide content inside a div in the middle of the screen/page while scrolling down/up (reverse) with the BROWSER SCROLLBAR?? 那么,如何在使用浏览器滚动条向下/向上滚动(反向)时显示/隐藏屏幕/页面中间的div中的内容?

What you are trying to do is called "scroll spying" -- essentially firing events based on where a user has scrolled to on a page. 您尝试执行的操作称为“滚动监视”-本质上是根据用户在页面上滚动到的位置触发事件。 If you search for "jQuery scroll spy plugin" you'll find many options to accomplish it. 如果您搜索“ jQuery滚动间谍插件”,则会找到许多实现它的选项。 Here's one that looks promising: https://github.com/sxalexander/jquery-scrollspy 这是一个看起来很有前途的: https : //github.com/sxalexander/jquery-scrollspy

Good luck! 祝好运!

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM