【问题标题】:jump page hyperlink not working. [duplicate]跳转页面超链接不起作用。 [复制]
【发布时间】:2018-12-12 20:53:13
【问题描述】:

我正在使用超链接来跳转页面以及在我的网页上切换页面。

我很难让我的超链接正常工作。我不知道为什么。

我使用下面的代码来换页

<a href="secondpage.html">secondpage</a>

和下面的代码跳转页面

<a href="#!">jumppagedownwards</a>

(页面下方)

<a href="!"></a>

如何将跳转页面和轮班页面合并到一个超链接中?

我尝试了以下代码:

<a href="secondpage.html#!">secondpagefurtherdown</a>

由于某种原因,它正在处理某些链接,而其他链接仅在不跳转的情况下移动页面。

有没有更好的方法来写链接?

【问题讨论】:

  • 我永远不会期望! 是一个有效的锚名称。如果有效,则需要&lt;a name="!"&gt;&lt;/a&gt;。但是为什么不&lt;p id="furtherdownthepage"&gt;Start here...&lt;/p&gt; 而拥有&lt;a href="secondpage.html#furtherdownthepage"...

标签: html css hyperlink


【解决方案1】:

锚点和基本 html 用法:

.first-content{
  height:400px;
  width:400px;
  background-color:grey;
}
.second-content{
  height:400px;
  width:400px;
  background-color:green;
}
div{
margin-bottom:100px;
}
<div class="first-content">
  <a href="#second" name="first">go to second content</a>
</div>
<div class="second-content">
  <a href="#first" name="second">go to first content</a>
</div>

如果你想使用高级的scoll,可以看这个文档

https://css-tricks.com/snippets/jquery/smooth-scrolling/

您可以访问50 Best Smooth Scroll jQuery Plugins Of 2017

【讨论】:

  • 长期以来,使用ID代替命名锚点
【解决方案2】:

你应该尝试这样的想法: &lt;a href="http://www.mylink.html"&gt;link&lt;/a&gt;(外部网址)或 &lt;a href="./mylink.html"&gt;link&lt;/a&gt;(本地)

【讨论】:

  • 不,他不应该。那不是问题。问题是关于锚的
  • 那帖子标题错了,不是我的回答
  • 没有。他想跳转到页面中的特定点。非常清楚——即使没有使用锚这个词
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2013-08-14
  • 2012-09-06
  • 2014-02-03
  • 2016-02-25
  • 2013-05-22
  • 2011-03-26
相关资源
最近更新 更多