2017-04-22 143 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