gpt4 book ai didi

jquery - 我无法在 Bootstrap 4 导航栏周围放置容器

转载 作者:行者123 更新时间:2023-12-03 22:46:30 24 4
gpt4 key购买 nike

我试图在导航栏周围放置一个容器类,但是,切换开关移至移动 View 的中心。

<nav class="navbar navbar-toggleable-md navbar-light bg-faded" id="commRollover">
<div class="container">
<button class="navbar-toggler navbar-toggler-right" type="button" data-toggle="collapse" data-target="#navbarNav" aria-controls="navbarNav" aria-expanded="false" aria-label="Toggle navigation">
<span class="navbar-toggler-icon"></span>
</button>
<a class="navbar-brand" href="#"><img src="img/qube_navbar_brand.webp" width="126px" height="54px"></a>
<div class="collapse navbar-collapse justify-content-end" id="navbarNav">
<ul class="navbar-nav">
<li class="nav-item active">
<a class="nav-link" href="#">Home <span class="sr-only">(current)</span></a>
</li>
<li class="nav-item">
<a class="nav-link" href="#">Features</a>
</li>
<li class="nav-item">
<a class="nav-link" href="#">Pricing</a>
</li>
<li class="nav-item">
<a class="nav-link disabled" href="#">Disabled</a>
</li>
</ul>
</div>
</div>

</nav>

为了阻止这个,我添加了这个 jquery 代码:

if ($(window).width() < 960) {
$("#commRollover .container").removeClass("container");
}

但是,导航栏链接位于导航栏品牌下方,我不知道为什么。

这是Codepen

最佳答案

如果您尝试在容器内全屏显示灰色背景和导航栏,则需要执行以下操作...

<div class="bg-faded">
<div class="container">
<nav class="navbar navbar-toggleable-md navbar-light" id="commRollover">
<button class="navbar-toggler navbar-toggler-right" type="button" data-toggle="collapse" data-target="#navbarNav" aria-controls="navbarNav" aria-expanded="false" aria-label="Toggle navigation">
<span class="navbar-toggler-icon"></span>
</button>
<a class="navbar-brand" href="#"><img src="img/qube_navbar_brand.webp" width="126px" height="54px"></a>
<div class="collapse navbar-collapse justify-content-end" id="navbarNav">
<ul class="navbar-nav">
<li class="nav-item active">
<a class="nav-link" href="#">Home <span class="sr-only">(current)</span></a>
</li>
<li class="nav-item">
<a class="nav-link" href="#">Features</a>
</li>
<li class="nav-item">
<a class="nav-link" href="#">Pricing</a>
</li>
<li class="nav-item">
<a class="nav-link disabled" href="#">Disabled</a>
</li>
</ul>
</div>
</nav>
</div>
</div>

http://www.codeply.com/go/bCO20TFmYw

关于jquery - 我无法在 Bootstrap 4 导航栏周围放置容器,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41838246/

24 4 0