需求:在页面中设置一个超链接,当点击这个超链接时,当前页指定的位置会直接划到页首。

实现:采用锚点实现。

案例代码:

<p><a href="#test1">点击这里跳转到锚点test1</a></p>
<p><a href="#test2">点击这里跳转到锚点test2</a></p>
中间省略若干行.....
<p id="test1">我是锚点test1</p>
中间省略若干行.....

<p id="test2">我是锚点test2</p>

 运行结果(下方可点击测试)

点击这里会让锚点test1应用上配置的属性

点击这里会让锚点test2应用上配置的属性

我是锚点test1

我是锚点test2

相关文章:

  • 2021-12-14
  • 2021-05-31
  • 2021-08-12
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2022-01-28
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-07-15
  • 2021-05-22
相关资源
相似解决方案