Bootstrap - navbar-fixed-top covers content

徘徊边缘 提交于 2020-01-01 08:14:09

问题


I have a question about navbar-fixed-top. Well, I have a simple problem with it. My fixed navbar covers content, for example in "About us" page, it covers row with "About us" title.

I have no idea how can I fix it, because when I resize website (mobile devices size) the header is visible.

Of course I have this kind of problem with headers in other pages (Full Width and 404).

Also, in Index page, it covers some of carousel slider.

Information:

  • website: http://testerix.site90.com/index.html

  • bootstrap 2.3.2

Let me know, how can I fix it on all resolutions.


回答1:


the response is in the page:

Twitter Bootstrap - top nav bar blocking top content of the page

Add to your CSS:

body { 
    padding-top: 65px; 
}

or a more complex solution but responsive, if your navbar change the height( ex in tablets appears in more to 60px; or is different ) use a mixed solution with css and javascript

CSS:

    #godown{
   height: 60px;
}

HTML (resumen)

<body>
<nav class="navbar navbar-fixed-top " role="navigation" id="navMenu">
...

</nav>

<!-- This div make the magic :) -->

<div class="godown-60" id="godown"></div>

<!-- the rest of your site -->
...

JAVASCRIPT:

<script>
//insert this in your jquery
//control the resizing of menu and go down the content in the correct position

    $("#navMenu").resize(function () {
        $('#godown').height($("#navMenu").height() + 10);
    });

    if ($("#navMenu").height() > $('#godown').height()) $('#godown').height($("#navMenu").height() + 10);

</script>



回答2:


Try class="navbar-static-top". It still allows navigation bar to be stay on the top but doesn't block content.




回答3:


I would do this:

// add appropriate media query if required to target mobile nav only
.nav { overflow-y: hidden !important }

This should make sure the nav block doesn't stretch downpage and covers the page content.




回答4:


position: sticky instead of position: static did the trick for me.




回答5:


Just add an id or class to the content, and then give it a margin top enough to make the content show without the static navbar hindering it and add the "!important" attribute to make it work.....



来源:https://stackoverflow.com/questions/19741145/bootstrap-navbar-fixed-top-covers-content

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!