链接按钮和文本部分

时间:2017-09-27 23:26:18

标签: javascript html css

我很困惑如何将导航栏的按钮链接到HTML中网站同一页面的某些文本。

2 个答案:

答案 0 :(得分:1)

这是一个jquery插件,只执行Scroll To。如果您有限制,也可以使用许多其他框架。

答案 1 :(得分:1)

这很简单,只需使用href <a href="#target"></a>滚动,并将<h1 id="target"></h1>标识为目标:

#wrapper {
  background-color: violet;
  width: 300px;
  height: 300px;
  overflow-y: auto;
}
<a href="#target">Scroll</a>
<div id="wrapper">
  text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text 
  <h1 id="target">TARGET</h1>
</div>