0

我正在使用一个 html 5 模板,它基本上有 1 个大索引 html 文件并使用锚点(id="")并打开“新”页面。

这是我的网站:http ://www.plans4canada.ca

现在在此页面上:http ://www.plans4canada.ca/#phones ,我想在顶部放置一个链接,该链接将在页面“内”跳转。基本上希望在顶部有 3 个链接,它们将跳转到计划 AC(有点多余)、DE 和底部的 FH。

我尝试添加 id,但这会“打开”一个新页面,而不仅仅是向下滚动。

有什么帮助吗?对不起,html菜鸟:)

4

2 回答 2

0

尝试平滑滚动

https://github.com/cferdinandi/smooth-scroll

于 2017-03-20T15:50:00.163 回答
0

您可以使用 Javascript。让你的锚点 onclick 隐藏所有其他的东西,只显示电话选项卡。其余的也一样。明白了吗:

.nav {
  text
}
body {
  font-family: sans-serif;
}
button {
  background: white;
  border: 1px solid black;
  padding: 10px 20px;
  font-size: 15px
}
<div class='nav'>
<button onclick='document.getElementById("phone").style.display = "block"; document.getElementById("plans").style.display = "none";'>Phones</button>
<button onclick='document.getElementById("plans").style.display = "block"; document.getElementById("phone").style.display = "none"'>Plans</button>
</div>
<div id='phone'>
Here is the information of your phone page. The other page are set to <code>Display: none</code> by default, so I made a button that will show the phone page onclick, and also hide the plans page.
</div>
<div id='plans' style='display:none'>
Placeholder
</div>

于 2017-03-12T02:02:19.537 回答