非常简单,但我对Bootstrap非常业余。
我理解如何使用图像作为品牌和导航项来制作导航栏。没有黑客攻击,有没有一种正确的方法让品牌定位在扩展导航之上?
基本上寻找这个;
EXPANDED ----------------------------------------- | Logo | ----------------------------------------- | Home About Contact | ----------------------------------------- COLLAPSED ----------------- | Logo ≡ | -----------------
<nav class="mainNav navbar navbar-expand-md justify-content-center">
<a class="navbar-brand" href="#">
<img src="img/logo.png" alt="Logo" height="80px" width="auto">
</a>
<ul class="navbar-nav">
<li class="nav-item">
<a class="nav-link" href="#">Home</a>
</li>
<li class="nav-item">
<a class="nav-link" href="#">About</a>
</li>
<li class="nav-item">
<a class="nav-link" href="#">Contact</a>
</li>
</ul>
</nav>
答案 0 :(得分:3)
使用flex-column
使导航栏项目堆叠成2行(行)。
d-flex w-100
)mx-md-auto
(自动边距)将徽标置于更大的宽度上text-center
将navbar-nav
https://www.codeply.com/go/W9HQcd3Pyw
<nav class="mainNav navbar navbar-expand-md navbar-light flex-column">
<div class="w-100 d-flex">
<a class="navbar-brand mx-md-auto" href="#">
<img src="img/logo.png" alt="Logo" height="80px" width="auto">
</a>
<button class="navbar-toggler ml-auto" type="button" data-toggle="collapse" data-target=".navbar-collapse">
<span class="navbar-toggler-icon"></span>
</button>
</div>
<div class="collapse navbar-collapse">
<ul class="navbar-nav text-center">
<li class="nav-item">
<a class="nav-link" href="#">Home</a>
</li>
<li class="nav-item">
<a class="nav-link" href="#">About</a>
</li>
<li class="nav-item">
<a class="nav-link" href="#">Contact</a>
</li>
</ul>
</div>
</nav>
详细了解Bootstrap 4文档中的Navbar和Utility类。
相关问题
How to centre navbar logo in Boostrap 4 with nav-links below
Bootstrap 4: Navbar with logo and 2 rows
Bootstrap 4 navbar with 2 rows and inline form