top nav bar blocking top content of the page
Solution 1:
Adding a padding like that is not enough if you're using responsive bootstrap. In this case when you resize your window you'll get a gap between top of the page and navbar. A proper solution looks like this:
body {
padding-top: 60px;
}
@media (max-width: 979px) {
body {
padding-top: 0px;
}
}
Solution 2:
Add to your CSS:
body {
padding-top: 65px;
}
From the Bootstrap docs:
The fixed navbar will overlay your other content, unless you add padding to the top of the body.
Solution 3:
For bootstrap 3, the class navbar-static-top
instead of navbar-fixed-top
prevents this issue, unless you need the navbar to always be visible.
Solution 4:
a much more handy solution for your reference, it works perfect in all of my projects:
change your first 'div' from
<div class='navbar navbar-fixed-top'>
to
<div class="navbar navbar-default navbar-static-top">
Solution 5:
I am using jQuery to solve this problem. This is the snippet for BS 3.0.0:
$(window).resize(function () {
$('body').css('padding-top', parseInt($('#main-navbar').css("height"))+10);
});
$(window).load(function () {
$('body').css('padding-top', parseInt($('#main-navbar').css("height"))+10);
});