我有一个固定位置的元素,我想在用户滚动到视口(viewport)折叠下方时有条件地显示它。具体来说,我在页面底部附加了一个链接,可以将用户带到页面顶部。没有理由显示链接,除非 body
大于 100vh
并且用户滚动到初始折叠下方。这可能只使用 CSS 吗?
图表:
_______________________
| |
| document text |
| document text |
| document text |
| document text |
| document text |
|-----------------------| <-- viewport fold
| document text |
| document text |
| document text |
| Top ↑ | <-- only show this link when below the fold
|_______________________|
最佳答案
这是 CSS 做不到的。只有使用 Javascript 才有可能。
关于css - 仅在折叠下方滚动时显示一个元素,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39421734/