【问题标题】:Is it possible to stick when the StickyContainer top is something different than 0?当 StickyContainer 顶部与 0 不同时,是否可以粘贴?
【发布时间】:2018-02-11 21:32:17
【问题描述】:

我有一个固定的导航栏,高度为 50 像素。当 StickyContainer 顶部为 50 而不是 0 时,我想坚持。请问我该如何实现?

【问题讨论】:

    标签: react-sticky


    【解决方案1】:

    我明白了,

    <StickyContainer>
      <Sticky topOffset={-50}>
        ({style, isSticky}) => (
          <div style={{ ...style, paddingTop: isSticky ? '50px' : '0px' }}>
            ...
          </div>
        )
      </Sticky>
    </StickyContainer>
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2017-01-25
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多