【发布时间】:2018-02-21 16:48:03
【问题描述】:
我正在使用 react,我希望仅在用户在页面上向下滚动 150 像素后才显示标题。
所以当用户开始向下滚动时,我希望出现一个粘性标题。同样,当用户滚动到页面顶部时,粘性标题会消失。
<div className="container">
// display this on top of the page:
<JumbotronImage />
// display this when user starts to scroll, sticky on top of the page
<StickyHeader />
</div>
我尝试使用 window.addEventListener('scroll'... 进行此操作,我也尝试了 https://github.com/fisshy/react-scroll 但无法使其正常工作。有什么建议吗?
【问题讨论】:
标签: javascript html css reactjs