gpt4 book ai didi

css - 如何在 bootstrap 4 中为事件类导航项制作边框?

转载 作者:行者123 更新时间:2023-11-28 11:19:41 25 4
gpt4 key购买 nike

我想更改 nav-item 中的一些样式。我制作了另一个样式表,并在其中制作了这段代码。问题是在 Internet Explorer 中它工作正常但在 Firefox 中没有任何变化。我怎样才能对 nav-link active 进行一些更改?

例如,当导航处于事件状态时,我希望有一个底部边框。

<div class="container">
<nav class="navbar navbar-expand-lg navbar-light py-md-5">
<a class="navbar-brand" href="#">Navbar</a>

<div class="justify-content-end collapse navbar-collapse" id="navbarNavAltMarkup">
<div class="navbar-nav">
<a class="nav-item nav-link active" href="#">Home <span class="sr-only">(current)</span></a>
<a class="nav-item nav-link" href="#">ABOUT US</a>
<a class="nav-item nav-link" href="#">SERVICES</a>
<a class="nav-item nav-link" href="#">TEAM</a>
<a class="nav-item nav-link" href="#">CLIENTS</a>
<a class="nav-item nav-link" href="#">CONTACT</a>
</div>
</div>
</nav>
</div>

最佳答案

将此 css 添加到您的自定义样式中

.nav-item.active
{
border-bottom:2px solid #f00;
}

.nav-item.active
{
border-bottom:2px solid #f00;
}
  <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.4.1/jquery.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.7/umd/popper.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.3.1/js/bootstrap.min.js"></script>

<nav class="navbar navbar-expand-lg navbar-light py-md-5">
<a class="navbar-brand" href="#">Navbar</a>
<button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#collapsibleNavbar">
<span class="navbar-toggler-icon"></span>
</button>
<div class="justify-content-end collapse navbar-collapse" id="collapsibleNavbar">
<ul class="navbar-nav">
<li class="nav-item active">
<a class="nav-link" href="#">Home </a>
</li>
<li class="nav-item">
<a class="nav-link" href="#">ABOUT US</a>
</li>
<li class="nav-item">
<a class="nav-link" href="#">SERVICES</a>
</li>
<li class="nav-item">
<a class="nav-link" href="#">TEAM</a>
</li>
<li class="nav-item">
<a class="nav-link" href="#">CLIENTS</a>
</li>
<li class="nav-item">
<a class="nav-link" href="#">CONTACT</a>
</li>
</ul>
</div>
</nav>

关于css - 如何在 bootstrap 4 中为事件类导航项制作边框?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56745125/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com