使用Bootstrap 5与Bootstrap图标,我也扩大了图标使用font-size:1.5rem;
,但这打破了链接的垂直对齐(如果你删除的样式,你可以看到它的工作了,需要在全页模式)
我找不到正确的方法来再次垂直对齐它:
<link href="https://cdn.jsdelivr.net/npm/bootstrap-icons@1.10.2/font/bootstrap-icons.css" rel="stylesheet"/>
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.2.3/dist/js/bootstrap.bundle.min.js"></script>
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.2.3/dist/css/bootstrap.min.css" rel="stylesheet"/>
<!-- Navigation-->
<nav class="navbar navbar-expand-lg navbar-light fixed-top shadow-sm" id="mainNav">
<div class="container">
<a class="navbar-brand fw-bold" href="/">Navbar</a>
<button class="navbar-toggler" type="button" data-bs-toggle="collapse" data-bs-target="#navbarResponsive" aria-controls="navbarResponsive" aria-expanded="false" aria-label="Toggle navigation">
Menu
<i class="bi-list"></i>
</button>
<div class="collapse navbar-collapse" id="navbarResponsive">
<ul class="navbar-nav ms-auto me-4 my-3 my-lg-0 text-center d-flex align-items-center">
<li class="nav-item"><a class="nav-link me-lg-3" href="#">Menu Item #1</a></li>
<li class="nav-item"><a role="button" class="nav-link me-lg-3"><i class="bi bi-stack-overflow" style="font-size:1.5rem;"></i>Menu Item With Icon</a></li>
<li class="nav-item"><a class="nav-link me-lg-3" href="#">Menu Item #3</a></li>
</ul>
</div>
</div>
</nav>
1条答案
按热度按时间x6yk4ghg1#
尝试将“d-flex”和“align-items-center”类添加到该导航链接: