1

我正在尝试链接到页面的特定部分。我已将href="#disclaimer"属性添加到我希望访问的锚链接中,并且在要单击的实际链接上,我已将 href 链接属性设置为href="./terms-conditions.php/#disclaimer"

该站点是当前托管在 localhost MAMP 服务器上的静态站点,但我不明白为什么该链接不起作用。它确实进入了正确的页面,但没有直接进入#disclaimer该页面底部的href链接,并且页面全部损坏,没有任何样式。当我通过主导航菜单正常访问该页面时,该页面一切正常。

我很困惑——任何帮助都会很棒。

艾米丽

<!-- Code with link to click -->

<p>Copyright © 2019 All rights reserved. <a title="disclaimer" href="./terms-conditions.php/#disclaimer">Disclaimer.</a> Authorised and regulated by the Solicitors Regulation Authority of England and Wales with registered number xxxxxx.</p>

<!-- Code code on the page you arrive at -->

<h3><a class="td" href="#disclaimer">Disclaimer</a></h3>
<p>The information you obtain at this site is not, nor is it intended to be, legal advice. You should consult a solicitor for advice regarding your individual situation. We invite you to contact us and welcome your calls, letters and electronic mail. Contacting us does not create a solicitor-client relationship. Please do not send any confidential information to us until such time as a solicitor-client relationship has been established.</p>

4

1 回答 1

0

这就是你需要的!

(忽略巨大的div,它是表示它走到了正确的位置):)

  <p>Copyright © 2019 All rights reserved. <a title="disclaimer" 
  href="#disclaimer">Disclaimer.</a> Authorised and regulated by the 
  Solicitors Regulation Authority of England and Wales with registered 
  number 
  xxxxxx.</p>

    <!-- Spacer content -->
    <div style="height: 4000px">
    
    </div>

    <!-- Code code on the page you arrive at -->
    <h3><a class="td" id="disclaimer">Disclaimer</a></h3>
    <p>The information you obtain at this site is not, nor is it intended to be, legal advice. You should consult a solicitor for advice regarding your individual situation. We invite you to contact us and welcome your calls, letters and electronic mail. Contacting us does not create a solicitor-client relationship. Please do not send any confidential information to us until such time as a solicitor-client relationship has been established.</p>

那么,这行得通的原因是什么?

'#' 标记作为页面锚点运行,它在其中查找关联的 'id' 标记并导航到它。结果,单击锚标记时,您“将跳转到同一页面的相应部分”(参考

要使这项工作专门为您的网站工作,请使用以下代码:

<p>Copyright © 2019 All rights reserved. <a title="disclaimer" 
  href="./terms-conditions.php#disclaimer">Disclaimer.</a> Authorised and regulated by the 
  Solicitors Regulation Authority of England and Wales with registered 
  number 
  xxxxxx.</p>

    <!-- Spacer content -->
    <div style="height: 4000px">
    
    </div>

    <!-- Code code on the page you arrive at -->
    <h3><a class="td" id="disclaimer">Disclaimer</a></h3>
    <p>The information you obtain at this site is not, nor is it intended to be, legal advice. You should consult a solicitor for advice regarding your individual situation. We invite you to contact us and welcome your calls, letters and electronic mail. Contacting us does not create a solicitor-client relationship. Please do not send any confidential information to us until such time as a solicitor-client relationship has been established.</p>

于 2019-10-01T22:20:43.963 回答