简体   繁体   English

Bootstrap导航栏标题与小屏幕上的内容重叠

[英]Bootstrap navbar header overlaps content on small screens

I have created a bootstrap navbar and on small screens it overlaps the pages content. 我创建了一个bootstrap导航栏,在小屏幕上它与页面内容重叠。 Is there a way to push the content down when the navbar would overlap it? 当导航栏重叠时,有没有办法将内容推下来? Preferably it could be done in HTML or CSS. 优选地,它可以在HTML或CSS中完成。

<header class="navbar navbar-inverse navbar-fixed-top bs-docs-nav">
<div class="container-fluid">
<div class="navbar-header">
  <button class="navbar-toggle" type="button" data-toggle="collapse" data-target=".bs-navbar-collapse">
    <span class="sr-only">Toggle navigation</span>
    <span class="icon-bar"></span>
    <span class="icon-bar"></span>
    <span class="icon-bar"></span>
  </button>
    <a href="./" class="navbar-brand"><img id="topLogo" src="http://placehold.it/50x25" alt="LOGO HERE" class="img-responsive"></a>
</div>
<nav class="collapse navbar-collapse bs-navbar-collapse">
  <ul class="nav navbar-nav">
    <li>
      <a href="#">Getting started</a>
    </li>
        <li class="dropdown">
        <a href="#" class="dropdown-toggle" data-toggle="dropdown">Dropdown <b class="caret"></b></a>
        <ul class="dropdown-menu">
          <li><a href="#">Action</a></li>
          <li><a href="#">Another action</a></li>
          <li><a href="#">Something else here</a></li>
          <li><a href="#">Separated link</a></li>
          <li><a href="#">One more separated link</a></li>
        </ul>
      </li>
    <li>
      <a href="#">Components</a>
    </li>
    <li>
      <a href="#">JavaScript</a>
    </li>
    <li>
      <a href="#">Customize</a>
    </li>
  </ul>
   <ul class="nav navbar-nav navbar-right">
    <li class="active"><a href="register.php"><span class="glyphicon glyphicon-user"></span> Sign Up</a></li>
    <li><a href="login.php"><span class="glyphicon glyphicon-log-in"></span> Login</a></li>
  </ul>
</nav>
</div>
</header>
<div class="container-fluid">
<h1>Text 1</h1>
<h2>Text 2</h2>
<h3>Text 3</h3>
<h4>Text 4</h4>
<h5>Text 5</h5>
<h6>Text 6</h6>
</div>

I've tried changing the navbar-fixed-top to both static and non fixed, however changing to makes the navbar not start at the top of the page 我已经尝试将navbar-fixed-top更改为静态和非固定,但更改为使导航栏无法从页面顶部开始

http://jsfiddle.net/7v9tcc2m/3/ http://jsfiddle.net/7v9tcc2m/3/

When you use the class navbar-fixed-top the navbar will overlap the content. 当您使用navbar-fixed-top类时, navbar-fixed-top栏将与内容重叠。 Remove this and then it'll work as expected 删除它,然后它将按预期工作

Following from your comment. 以下是您的评论。 The reason why you have space between the top and the nav is because you've got padding on the body.. remove this then it will work. 你在顶部和导航之间有空间的原因是因为你在身体上有padding 。删除它然后它会起作用。

Demo here 在这里演示

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

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