Boostrap使用固定的导航栏和锚标签跳转到部分 [英] Boostrap using fixed navbar and anchor tags to jump to sections
本文介绍了Boostrap使用固定的导航栏和锚标签跳转到部分的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在尝试使用锚标签导航到使用引导程序和固定在顶部的导航栏的网页的特定部分。问题是,当我单击锚链接时,由于应用于正文的边距,它们不能正确滚动到该部分的开头,它滚动通过部分开始。
I am trying to use anchor tags to navigate to specific sections of a webpage using bootstrap and a navbar that is fixed to the top. The problem is when I click the anchor links, they don't correctly scroll to the start of the section, it scrolls past the section start, because of the margin applied to the body.
body {
margin-top: 60px;
}
我该如何解决这个问题?
How can I fix this?
请参阅以下jsFiddle获取完整演示: http://jsfiddle.net/6kwrY/
See the following jsFiddle for a full demo: http://jsfiddle.net/6kwrY/
推荐答案
解决方案是使用:
The solution is to use:
.section {
padding-top: 60px;
margin-top: -60px;
}
这篇关于Boostrap使用固定的导航栏和锚标签跳转到部分的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文