一、页面内跳转的锚点设置
页面内的跳转需要两步:
方法一:
①:设置一个锚点链接去找喵星人;(注意:href属性的属性值最前面要加#)
②:在页面中需要的位置设置锚点;(注意:a标签中要写一个name属性,属性值要与①中的href的属性值一样,不加#)标签中按需填写必要的文字,一般不写内容
方法二:
①:同方法一的①
②:设置锚点的位置
小案例:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html;charset=UTF-8">
<title>萌宠集结号</title>
</head>
<body>
<ul>
<li><a href="#miao">去找喵星人</a></li>
<li><a href="#wang">去找汪星人</a></li>
<li><a href="#meng">其他萌物</a></li>
</ul>
<a name="miao"></a><!--设置锚点方法1-->
<h3 id="miao">喵星人基地</h3><!--设置锚点方法2-->
<p>喵喵喵~</p><p><span>立即学习</span>“<a href="https://pan.quark.cn/s/cb6835dc7db1" style="text-decoration: underline !important; color: blue; font-weight: bolder;" rel="nofollow" target="_blank">前端免费学习笔记(深入)</a>”;</p>
<p>喵喵喵~</p><p><span>立即学习</span>“<a href="https://pan.quark.cn/s/cb6835dc7db1" style="text-decoration: underline !important; color: blue; font-weight: bolder;" rel="nofollow" target="_blank">前端免费学习笔记(深入)</a>”;</p>
<p>喵喵喵~</p><p><span>立即学习</span>“<a href="https://pan.quark.cn/s/cb6835dc7db1" style="text-decoration: underline !important; color: blue; font-weight: bolder;" rel="nofollow" target="_blank">前端免费学习笔记(深入)</a>”;</p>
<p>喵喵喵~</p><p><span>立即学习</span>“<a href="https://pan.quark.cn/s/cb6835dc7db1" style="text-decoration: underline !important; color: blue; font-weight: bolder;" rel="nofollow" target="_blank">前端免费学习笔记(深入)</a>”;</p>
<p>喵喵喵~</p><p><span>立即学习</span>“<a href="https://pan.quark.cn/s/cb6835dc7db1" style="text-decoration: underline !important; color: blue; font-weight: bolder;" rel="nofollow" target="_blank">前端免费学习笔记(深入)</a>”;</p>
<p>喵喵喵~</p><p><span>立即学习</span>“<a href="https://pan.quark.cn/s/cb6835dc7db1" style="text-decoration: underline !important; color: blue; font-weight: bolder;" rel="nofollow" target="_blank">前端免费学习笔记(深入)</a>”;</p>
<a name="wang"></a>
<p>汪汪汪~</p>
<div class="aritcle_card">
<a class="aritcle_card_img" href="/xiazai/code/10769">
<img src="https://img.php.cn/upload/webcode/000/000/003/176365080729654.jpg" alt="BIWEB WMS门户网站PHP开源建站系统5.8.3">
</a>
<div class="aritcle_card_info">
<a href="/xiazai/code/10769">BIWEB WMS门户网站PHP开源建站系统5.8.3</a>
<p>BIWEB 门户版几经周折,最终与大家见面了。BIWEB门户版建立在ArthurXF5.8.3底层上,有了更加强大的功能。 BIWEB WMS v5.8.3 (2010.1.29) 更新功能如下: 1.修正了底层getInfo方法中的调用参数,做到可以根据字段进行调用。 2.修正了栏目安装和卸载后,跳转链接的错误。 3.修正所有栏目分类系统,提交信息页面错误。 4.新增后台删除信息后仍停留原分</p>
<div class="">
<img src="/static/images/card_xiazai.png" alt="BIWEB WMS门户网站PHP开源建站系统5.8.3">
<span>0</span>
</div>
</div>
<a href="/xiazai/code/10769" class="aritcle_card_btn">
<span>查看详情</span>
<img src="/static/images/cardxiayige-3.png" alt="BIWEB WMS门户网站PHP开源建站系统5.8.3">
</a>
</div>
<p>汪汪汪~</p>
<p>汪汪汪~</p>
<p>汪汪汪~</p>
<p>汪汪汪~</p>
<p>汪汪汪~</p>
<a name="meng"></a>
<p>萌萌萌~</p>
<p>萌萌萌~</p>
<p>萌萌萌~</p>
<p>萌萌萌~</p>
<p>萌萌萌~</p>
<p>萌萌萌~</p>
</body>
</html>二、跨页面跳转
①:设置锚点链接,在href中的路径后面追加:#+锚点名,即可
如:跳转到萌宠集结号页面
②:要跳转到的页面中要设置锚点,方法见一种的步骤②,两个方法任选其一。
以上就是html中的锚点和页面跳转的详细内容,更多请关注php中文网其它相关文章!
HTML怎么学习?HTML怎么入门?HTML在哪学?HTML怎么学才快?不用担心,这里为大家提供了HTML速学教程(入门课程),有需要的小伙伴保存下载就能学习啦!
Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号