2017-04-22 146 views
1

我在HTML中的anchor标记有问题。它需要双击链接才能找到我放置anchor的位置,或者根本不起作用。锚定标记无法正常工作

下面是一个例子:

<nav> 
    <ul> 
     <li><a href="#opt">option1</a></li> 
    </ul> 
</nav> 

<div id="opt"> 

注意这个id几乎是在文档的末尾。在此之前div还有其他标签,如部分/标题的/文章/等。

我不知道以前的一些东西是否会干扰我的anchor标签。

注意:令人惊讶的是,在IE中它工作正常。问题出在Chrome上。

请让我知道,如果需要更多信息。

+0

在HTML中是否有一个或多个'id =“opt”'? – Badacadabra

+1

嗨@Badacadabra,我认为Adobe Brackets它搞砸了。我从文件本身打开html,它工作正常。我在Brackets中使用动态预览,也许它有一个错误。 – Maxi

+0

也许......感谢您的评论。 :) – Badacadabra

回答

0

<nav> 
 
    <ul> 
 
     <li><a href="#opt">option</a></li> 
 
     <li><a href="#opt1">option1</a></li> 
 
     <li><a href="#opt2">option2</a></li> 
 
     <li><a href="#opt3">option3</a></li> 
 
    </ul> 
 
</nav> 
 

 
<div id="opt"> 
 
<h1>option</h1> 
 
<p>Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum.</p> 
 
<br><br><br> 
 
</div> 
 
<div id="opt1"> 
 
<h1>option1</h1> 
 
<p>It is a long established fact that a reader will be distracted by the readable content of a page when looking at its layout. The point of using Lorem Ipsum is that it has a more-or-less normal distribution of letters, as opposed to using 'Content here, content here', making it look like readable English. Many desktop publishing packages and web page editors now use Lorem Ipsum as their default model text, and a search for 'lorem ipsum' will uncover many web sites still in their infancy. Various versions have evolved over the years, sometimes by accident, sometimes on purpose (injected humour and the like) 
 
</p> 
 

 
<br><br><br> 
 
</div> 
 
<div id="opt2"> 
 
<h1>option2</h1> 
 
<p>Contrary to popular belief, Lorem Ipsum is not simply random text. It has roots in a piece of classical Latin literature from 45 BC, making it over 2000 years old. Richard McClintock, a Latin professor at Hampden-Sydney College in Virginia, looked up one of the more obscure Latin words, consectetur, from a Lorem Ipsum passage, and going through the cites of the word in classical literature, discovered the undoubtable source. Lorem Ipsum comes from sections 1.10.32 and 1.10.33 of "de Finibus Bonorum et Malorum" (The Extremes of Good and Evil) by Cicero, written in 45 BC. This book is a treatise on the theory of ethics, very popular during the Renaissance. The first line of Lorem Ipsum, "Lorem ipsum dolor sit amet..", comes from a line in section 1.10.32.</p> 
 

 
<br><br><br> 
 
</div> 
 
<div id="opt3"> 
 
<p>The standard chunk of Lorem Ipsum used since the 1500s is reproduced below for those interested. Sections 1.10.32 and 1.10.33 from "de Finibus Bonorum et Malorum" by Cicero are also reproduced in their exact original form, accompanied by English versions from the 1914 translation by H. Rackham. 
 
</p> 
 

 
<br><br><br> 
 
</div>

0

其它标签将不会改变锚标记的默认行为。另外,如果它在其他浏览器(例如IE)中有效,我假定文档中没有脚本也会修改链接的行为。

由于知道Chrome出现问题,我怀疑是Chrome扩展,或者有时(修改版)浏览器本身就是罪魁祸首。请查看您的浏览器版本和扩展。

+0

HI @Arga谢谢你的评论!我会看看这个 – Maxi