悬停时页内锚点字形的CSS

时间:2016-05-18 17:25:14

标签: twitter-bootstrap-3

我试图复制我在Bootstrap文档和其他地方看到的效果:

当您将鼠标悬停在h1 / h2 / h3等上方时,会出现一个字形,您可以复制/粘贴包含片段标识符的网址,例如http://foo.com/woof.html#page_fragment

照片:

The "chain" icon only shows on the left on hover

"链"图标仅在悬停时显示在左侧

问题:这种影响可以从Bootstrap库或其他地方获得吗?

这种用户体验的名称是什么?

2 个答案:

答案 0 :(得分:1)

就像你注意到引导程序没有本地方法那样:但是,使用少量css和html它将完美地工作:

工作小提琴:https://jsfiddle.net/5of43a4r/

CSS:

h1:hover a.anchorjs-link {
    display: block !important;
}

HTML:

<h1>
  <a class="anchorjs-link" href="#page_fragment" style="position: absolute; margin-left: -1em; padding-right: 0.5em;display: none">
  <span class="glyphicon glyphicon-link" aria-hidden="true"></span> </a>
  H1 TEXT
</h1>

答案 1 :(得分:1)

从Sébastien的回答中的“anchorJS”线索开始,我发现了Bootstrap Anchor,“缺少用于锚定支持的Bootstrap插件。”

相关问题