gpt4 book ai didi

html - 删除导航项下拉列表之间的空格,默认行为无法正常工作

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

我正在尝试在应用程序的标题上添加 Bootstrap 菜单,几乎一切正常,但在 <nav> 上使用时<li class='nav-item dropdown'> ,它会添加一个空白空间并且不会在响应模式下折叠。

我在右侧添加了一个带有品牌的简单菜单,其结构如下:

>Menu
--Home
--Link
--Dropdown
---Action
---Another action
---Something else
--Another dropdown
---Action
---Another action
---Something else
--Disabled
>Brand

在桌面模式下,菜单正确显示。

<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<script src="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/js/bootstrap.min.js"></script>
<link href="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css" rel="stylesheet"/>
<nav class="navbar navbar-expand-lg navbar-light bg-light">
<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">
<ul class="navbar-nav mr-auto">
<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="#">Link</a>
</li>
<li class="nav-item dropdown">
<a class="nav-link dropdown-toggle" href="#" id="navbarDropdown" role="button" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
Dropdown
</a>
<div class="dropdown-menu" aria-labelledby="navbarDropdown">
<a class="dropdown-item" href="#">Action</a>
<a class="dropdown-item" href="#">Another action</a>
<div class="dropdown-divider"></div>
<a class="dropdown-item" href="#">Something else here</a>
</div>
</li>
<li class="nav-item dropdown">
<a class="nav-link dropdown-toggle" href="#" id="navbarDropdown" role="button" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
Another dropdown
</a>
<div class="dropdown-menu" aria-labelledby="navbarDropdown">
<a class="dropdown-item" href="#">Action</a>
<a class="dropdown-item" href="#">Another action</a>
<div class="dropdown-divider"></div>
<a class="dropdown-item" href="#">Something else here</a>
</div>
</li>
<li class="nav-item">
<a class="nav-link disabled" href="#">Disabled</a>
</li>
</ul>
<a class="navbar-brand" href="#">Navbar</a>
</div>
</nav>

我的输出需要是这样的:

Target

相反,我得到这个:

Current

最佳答案

尝试在 CSS 中编辑它们。

.nav-item{
line-height: normal;
}

关于html - 删除导航项下拉列表之间的空格,默认行为无法正常工作,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56742086/

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