我正在使用Laravel和Bootstrap CSS框架构建一个网站。我在页面顶部有一个导航栏,用于浏览不同的页面。默认情况下,Laravel将导航栏类设置为navbar-light
。由于我不希望导航栏为白色,因此我将其更改为navbar-dark
。当我这样做时,导航栏中的所有内容都会消失,只剩下没有任何内容的白条。我做错了什么?
<nav class="navbar navbar-expand-md navbar-dark navbar-laravel" style="margin-bottom: 20px;">
<div class="container">
<a class="navbar-brand" href="{{ url('/') }}">
{{ config('app.name', 'Laravel') }}
</a>
<button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarSupportedContent" aria-controls="navbarSupportedContent" aria-expanded="false" aria-label="Toggle navigation">
<span class="navbar-toggler-icon"></span>
</button>
<div class="collapse navbar-collapse" id="navbarSupportedContent">
<!-- Left Side Of Navbar -->
<ul class="navbar-nav mr-auto">
<li class="nav-item">
<a class="nav-link" href="/">Home <span class="sr-only">(current)</span></a>
</li>
<li class="nav-item">
<a class="nav-link" href="#">Messages <span class="sr-only">(current)</span></a>
</li>
<li class="nav-item">
<a class="nav-link" href="#">People <span class="sr-only">(current)</span></a>
</li>
<li class="nav-item">
<a class="nav-link" href="#">Photos <span class="sr-only">(current)</span></a>
</li>
</ul>
<!-- Right Side Of Navbar -->
<ul class="navbar-nav ml-auto">
<!-- Authentication Links -->
@guest
<li><a class="nav-link" href="{{ route('login') }}">Login</a></li>
<li><a class="nav-link" href="{{ route('register') }}">Register</a></li>
@else
<li class="nav-item dropdown">
<a class="nav-link dropdown-toggle" href="#" role="button" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
{{ Auth::user()->name }} <span class="caret"></span>
</a>
<div class="dropdown-menu" aria-labelledby="navbarDropdown">
<a class="dropdown-item" href="dashboard">
Dashboard
</a>
<a class="dropdown-item" href="{{ route('logout') }}"
onclick="event.preventDefault();
document.getElementById('logout-form').submit();">
Logout
</a>
<form id="logout-form" action="{{ route('logout') }}" method="POST" style="display: none;">
@csrf
</form>
</div>
</li>
@endguest
</ul>
</div>
</div>
</nav>
答案 0 :(得分:4)
您还需要将bg-dark
添加到navbar-dark
。
navbar-dark
基本上只确定文本应该是什么颜色,即深色背景导航栏的浅色文本和浅色导航栏的深色文本。
bg-dark
确定导航栏的实际背景颜色。但其他颜色也可以。例如,bg-primary
或bg-danger
可与navbar-dark
配合使用。
答案 1 :(得分:0)
添加<nav class="navbar navbar-expand-md navbar-dark bg-dark navbar-laravel">
类
{{1}}