【问题标题】:Anchor Tag Not Working Properly锚标记无法正常工作
【发布时间】:2017-04-22 01:14:04
【问题描述】:

我对 HTML 中的 anchor 标记有疑问。需要双击链接才能找到我放置anchor 的位置,或者有时根本不起作用。

这是一个例子:

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

<div id="opt">

请注意,id 几乎位于文档的末尾。在此div 之前还有其他标签,如sections/header's/articles/ 等。

不知道之前的一些东西会不会打扰到我的anchor标签。

注意:令人惊讶的是,它在 IE 中运行良好。问题出在 Chrome 中。

如果需要更多信息,请告诉我。

【问题讨论】:

  • 您的 HTML 中是否有一个或多个 id="opt"
  • 嗨@Badacadabra,我认为Adobe Brackets 把事情搞砸了。我从文件本身打开了 html,它工作正常。我在括号中使用动态预览,也许它有一个错误。
  • 也许...感谢您的评论。 :)

标签: html tags anchor


【解决方案1】:

<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>

【讨论】:

    【解决方案2】:

    其他标签不会改变锚标签的默认行为。此外,如果它适用于其他浏览器,即 IE,我假设您的文档中也没有修改链接行为的脚本。

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

    【讨论】:

    • 嗨@Arga 感谢您的评论!我去看看
    猜你喜欢
    • 1970-01-01
    • 2015-07-26
    • 1970-01-01
    • 2015-08-01
    • 1970-01-01
    • 1970-01-01
    • 2016-04-13
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多