【问题标题】:Links in a single page wordpress theme单页 wordpress 主题中的链接
【发布时间】:2013-05-03 13:57:17
【问题描述】:

我正在构建单页 WordPress 主题(index.php 包括 header.php 和 footer.php)

网站内部的导航是通过jquery div隐藏和显示来完成的...

因此,页面的 url 不会改变,但我想让它成为可能,以便人们可以共享特定部分(或状态)和书签的链接,并具有后退按钮功能。怎么做?

【问题讨论】:

  • 我听说我可以通过使用 Hashbangs 或 html5 推送状态来实现这一点......但我不知道该怎么做!

标签: jquery wordpress hyperlink wordpress-theming


【解决方案1】:

您可以在链接中使用主题标签:

HTML:

<a href='#sectionOne'>SectionOne</a>
<a href='#sectionTwo'>SectionTwo</a>

<section id='sectionOne'>Hey there, I'm section One</section>
<section id='sectionTwo'>Hey there, I'm section Two</section>

CSS:

section {
  display: none;
}

section:target {
  display: block;
}

点击您的链接将在您的浏览器中创建一个以#sectionOne 结尾的网址,便于收藏。此外,根据您的 CSS,当您将 :target 选择器放入 CSS 中时,特定的 #sectionOne 将可见:

演示:http://jsbin.com/ogodeg/1

【讨论】:

  • 这很好,但它并不能帮助我处理 jquery 动画和状态......但还是谢谢!
【解决方案2】:

您正在寻找deep linking

jQuery Address* 它是一个深度链接插件,支持跨浏览器。

*Github 本身就有你要找的功能,在浏览项目源代码时检查幻灯片过渡。虽然github的深度链接only works with the History API.

【讨论】:

  • 是的,另一种方法是使用History API
猜你喜欢
  • 1970-01-01
  • 2012-10-05
  • 1970-01-01
  • 2012-04-18
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2018-07-14
相关资源
最近更新 更多