【问题标题】:Anchor with hash fragment is not navigating to matching id带有哈希片段的锚未导航到匹配的 id
【发布时间】:2017-02-02 01:45:21
【问题描述】:

我有一个带有哈希片段的锚:

<a href="#people">People</a>

在我的页面下方,我有一个具有匹配 ID 的部分:

<section id="people">...</section>

点击链接时,URL 会更新,但页面不会移动到该部分。

你可以在这里试一试,所有的nav项都有hash片段,页面上的每个部分都有一个匹配的ID:https://react-test-don.herokuapp.com

为什么单击我的锚标记没有任何作用?

【问题讨论】:

标签: html anchor react-router


【解决方案1】:

为此我使用

<a name="subject"></a> - At the position in the page where I want to go
<a href="#subject">Go to subject</a> For the link to jump there

查看我的页面 - 你应该可以查看源代码

Here

只需向下滚动到显示“在此页面上”的位置,就会有几个链接将您带到页面的不同部分。

【讨论】:

    猜你喜欢
    • 2019-08-31
    • 2015-06-02
    • 2021-05-08
    • 1970-01-01
    • 2014-08-26
    • 2021-11-13
    • 2020-08-08
    • 1970-01-01
    • 2017-11-07
    相关资源
    最近更新 更多