<分区>
标签 javascript jquery html css
<分区>
我有一个 97px 的固定标题。我还设置了跳转到页面每个部分的 anchor 标记。我的网页设置 anchor 标签的方式是通过隐藏在固定标题后面的页面标题跳转到正确的位置。
为了按照我希望的方式工作, anchor 标签也需要从它们当前跳转的位置跳转 -97 像素?
我怎样才能做到这一点?
我的 href
跳转到标签的例子是:
<a href="#contact">Contact</a>
<a id="contact"name="contact"></a>
最佳答案
有一个已知的 hack,涉及在 anchor 上设置边距和填充。
在你的 anchor ('jump')标签上......
<a id="contact" style="padding-top: 80px; margin-top: -80px;">
查看此网站的示例:
关于javascript - 避免固定 header 的 anchor 标记,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28351840/
相关文章:
javascript - 如何将类的实例添加到 JavaScript 对象中?
jquery - jQuery jqGrid 的自定义下拉格式化程序
javascript - 使用 jQuery 在 HTML 页面之间转换?
python - 使用 django 在 HTML 页面中显示数据库中的数据
javascript - 我需要一个 html 音频元素来使用网络音频 api 播放歌曲吗
javascript - 三个JS : How to remove vertices?
javascript - 在 WebView 中提交表单 - Swift 3.1