【问题标题】:Scroll to a position relative to an anchor滚动到相对于锚点的位置
【发布时间】:2011-11-23 05:32:06
【问题描述】:

我想滚动到锚点上方 20 像素的位置。最好的解决方案是什么?

编辑:我将使用scrollTo with jquery。无法计算出 window.location.hash。

【问题讨论】:

  • 您还需要这样做吗?我错过了编辑,请参阅。

标签: javascript jquery html scroll anchor


【解决方案1】:

例如,滚动到锚点(可能通过设置window.location.hash)然后执行window.scrollBy(0, -20)

【讨论】:

    猜你喜欢
    • 2020-05-02
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-08-01
    • 2023-03-23
    • 1970-01-01
    相关资源
    最近更新 更多