片段链接不工作 [英] Fragment link not working

查看:96
本文介绍了片段链接不工作的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

总新手问题,但我无法弄清楚我做错了什么。我想要一个链接将页面跳转到标题。我相信这些被称为片段链接。这里是我的代码不工作:

 < a href =#Frag>我的链接< / a> 

< div id =cont>

这里有很多内容,在本例中缩写以节省空间< / p>

< h2 id =Frag>标题我想跳转到< / h2>
< / div>


解决方案

好名字而不是id ..



http ://www.w3schools.com/tags/att_a_name.asp



如果你想有一个很好的滚动,你可以使用jquery scroll http://api.jquery.com/scroll/


Total newbie question, but I cant figure out what im doing wrong. I want a make a link that jumps down the page to a header. I believe these are called fragment links. Here is my code thats not working:

<a href="#Frag">My Link</a>

<div id="cont">

<p>Lots of content here, abbreviated in this example to save space</p>

<h2 id="Frag">Header I want to jump to</h2>
</div>

解决方案

Your code works fine in firefox anyway you can use as well name instead of id..

http://www.w3schools.com/tags/att_a_name.asp

if you want to have a nice scrolling you can use jquery scroll http://api.jquery.com/scroll/

这篇关于片段链接不工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆