我怎样才能 link 按钮在 html 到另一个 class/div

How can i link button in html to another class/div

我有一个 1 页的网站,我如何 link 我的按钮,如果我点击它,它会下降到我的页脚 ID 我的页脚是 Footersite

我的代码:

<div class="openbutton">
    <a href="Footersite">
       <p style="color: white; font-size: 17px;">Contact us</p>
    </a>
</div>

但它并没有下降。我该如何解决这个问题?

只需使用锚点link即可实现:

<div class="openbutton">

  <a href="#Footersite">
    <p style="color: white;font-size: 17px;">
      Contact us
    </p>
  </a>

</div>

<a name="Footersite"></a>
<div style="margin:1000px 0;">
  Footersite
</div>

即使您可以使用锚标记实现此目的,但这不是唯一的方法。使用 button 元素你可以实现这个

HTML 按钮

div {
  margin-top: 800px;
  width: 100px;
  height: 100px;
  background: tomato;
}
<button onclick="window.location.href='#abc'">Button</button>
<div id="abc"></div>

DEMO

如果你想要锚元素,那么

锚标签

div {
  margin-top: 800px;
  width: 100px;
  height: 100px;
  background: tomato;
}
<a href="#abc">Link</a>
<div id="abc"></div>