我创建了一个bootstrap导航栏,在小屏幕上它与页面内容重叠。当导航栏重叠时,有没有办法将内容推下来?最好是用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>
我已尝试将导航栏固定顶部更改为静态和非固定,但更改为使导航栏无法从页面顶部开始
答案 0 :(得分:3)
当您使用课程navbar-fixed-top
时,导航栏会与内容重叠。删除它,然后它将按预期工作
关注你的评论。你在顶部和导航之间有空格的原因是因为你身上有padding
..删除它然后它会起作用。
演示 here