【锚点】

第一种跳转:(同一页面中跳转,使用name定位)

  使用name属性只能针对a标签来定位,而对div等其它标签就不能起到定位作用

<a href="#q1">问题一?</a>
<a href="#q2">问题二?</a>
<a href="#q3">问题三?</a>

<a name="q1">问题一的解答</a> 
<a name="q2">问题二的解答</a> 
<a name="q3">问题三的解答</a>

 第二种跳转:(同一页面中跳转,使用id定位)

  使用id属性可以对其它标签进行定位

<a href="#q1">问题一?</a>
<a href="#q2">问题二?</a>
<a href="#q3">问题三?</a>

<p name="q1">问题一的解答</p> 
<div name="q2">问题二的解答</div> 
<h1 name="q3">问题三的解答</h1>

第三种跳转:(跨页面跳转,使用name或id定位)

a.html的内容 <a href="b.html#q1">问题一?</a>
b.html的内容 <a name="q1">问题一的解答</a>

第四种跳转:(定义好锚点,使用js进行跳转)

<head>
    <meta http-equiv="Content-Type" content="text/html;charset=utf-8">
    <title>使用锚链接到同一个网页的不同部分</title>
    <script type="text/javascript">
        location.hash="#html";
    </script>
</head>
终身学习者
原文地址:https://www.cnblogs.com/zuixinxian/p/4948508.html