简体   繁体   English

引导程序固定菜单隐藏内容

[英]Bootstrap fixed menu hiding content

I am using bootstrap fixed menu in my web page, but the menu bar is hiding some of the content of the page, especially when the screen size is decreased, then the responsive menu will hide more content. 我在网页中使用引导固定菜单,但是菜单栏隐藏了页面的某些内容,尤其是当屏幕尺寸减小时,自适应菜单将隐藏更多内容。

example of the code: 代码示例:

 <nav class="navbar navbar-inverse navbar-fixed-top" style ="background:#141414"> <div class="container-fluid"> <div class="navbar-header"> <a class="navbar-brand navbar-left" href="#" style="font-family:'Adobe Arabic';font-size:xx-large; font-weight:bold;"><?php echo $strMnuBrand; ?> </a> </div> <ul class="nav navbar-nav navbar-left"> <li class="active" ><a href="#" style="background:#ff6600; color:#e7e7e7; font-weight:bold;"><?php echo $strMnuHome ?></a></li> <li><a href="#" style="color:#e7e7e7;"><?php echo $strMnuPage1 ?></a></li> <li><a href="#" style="color:#e7e7e7;"><?php echo $strMnuPage2 ?></a></li> </ul> 

...etc. ...等等。 What I should do so the fixed menu do not hide the page content, and the page stay responsive? 我应该怎么做才能使固定菜单不会隐藏页面内容,并使页面保持响应状态?

note: I searched SO for solution but no one worked for me! 注意:我在SO中寻找解决方案,但没人为我工作!

You need to add top padding equal to the height of your navbar + a bit for padding to your body, if you're using top-fixed navbar. 如果您使用的是顶部固定的导航栏,则需要添加等于导航栏高度的顶部填充+一点点填充到您的身体。 Like so: 像这样:

body {
  padding-top: 70px;
}

Make sure to include this after the core Bootstrap CSS. 确保在核心Bootstrap CSS之后添加此名称。

The below code will not hide any of the menu items when the screen size is reduced and will also be responsive and will show the menu items at all screen sizes. 当屏幕尺寸减小时,以下代码将不会隐藏任何菜单项,并且也会响应,并且将在所有屏幕尺寸下显示菜单项。

You can see it in action here 您可以在这里看到它的运行情况

<nav class="navbar navbar-inverse">
  <div class="container-fluid">
    <div class="navbar-header">

      <a class="navbar-brand" href="#">Brand Name</a>
    </div>
    <div class="" id="myNavbar">
      <ul class="nav navbar-nav">
        <li class="active"><a href="#">Home</a></li>
        <li class="dropdown">
          <a class="dropdown-toggle" data-toggle="dropdown" href="#">Page 1 <span class="caret"></span></a>
          <ul class="dropdown-menu">
            <li><a href="#">Page 1-1</a></li>
            <li><a href="#">Page 1-2</a></li>
            <li><a href="#">Page 1-3</a></li>
          </ul>
        </li>
        <li><a href="#">Page 2</a></li>
        <li><a href="#">Page 3</a></li>
      </ul>
      <ul class="nav navbar-nav navbar-right">
        <li><a href="#"><span class="glyphicon glyphicon-user"></span> Sign Up</a></li>
        <li><a href="#"><span class="glyphicon glyphicon-log-in"></span> Login</a></li>
      </ul>
    </div>
  </div>
</nav>  

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM