如何使用Bootstrap 5.1正确嵌套列表组?
我正在尝试使用 bootstrap 5.1 list component 创建多级级别列表组。
这是我所做的
<link href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-0evHe/X+R7YkIZDRvuzKMRqM+OrBnVFBL6DOitfPri4tjfHxaWutUpFmBp4vmVor" crossorigin="anonymous">
<h2>Standard</h2>
<ul class="list-group">
<li class="list-group-item"><a href="/">First</a></li>
<li class="list-group-item"><a href="/">Second</a>
<ul class="list-group">
<li class="list-group-item"><a href="/">Level 2 - First</a></li>
<li class="list-group-item"><a href="/">Level 2 - Second</a></li>
</ul>
</li>
<li class="list-group-item"><a href="/">Third</a></li>
</ul>
<h2 class="mt-5">With Flush</h2>
<ul class="list-group list-group-flush">
<li class="list-group-item"><a href="/">First</a></li>
<li class="list-group-item"><a href="/">Second</a>
<ul class="list-group list-group-flush">
<li class="list-group-item"><a href="/">Level 2 - First</a></li>
<li class="list-group-item"><a href="/">Level 2 - Second</a></li>
</ul>
</li>
<li class="list-group-item"><a href="/">Third</a></li>
</ul>
如以上示例所示,列表组看起来不正确。如何修复嵌套列表组的外观?
更新 在上面的标准示例中,我看到了嵌套菜单的间距问题。
在齐平示例中,底线应与所有情况相同,但是嵌套级别的凹痕应更大。
I am trying to use Bootstrap 5.1 list group component to create multi-level list group.
Here is what I did
<link href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-0evHe/X+R7YkIZDRvuzKMRqM+OrBnVFBL6DOitfPri4tjfHxaWutUpFmBp4vmVor" crossorigin="anonymous">
<h2>Standard</h2>
<ul class="list-group">
<li class="list-group-item"><a href="/">First</a></li>
<li class="list-group-item"><a href="/">Second</a>
<ul class="list-group">
<li class="list-group-item"><a href="/">Level 2 - First</a></li>
<li class="list-group-item"><a href="/">Level 2 - Second</a></li>
</ul>
</li>
<li class="list-group-item"><a href="/">Third</a></li>
</ul>
<h2 class="mt-5">With Flush</h2>
<ul class="list-group list-group-flush">
<li class="list-group-item"><a href="/">First</a></li>
<li class="list-group-item"><a href="/">Second</a>
<ul class="list-group list-group-flush">
<li class="list-group-item"><a href="/">Level 2 - First</a></li>
<li class="list-group-item"><a href="/">Level 2 - Second</a></li>
</ul>
</li>
<li class="list-group-item"><a href="/">Third</a></li>
</ul>
As you can see in the above example, the list group does not look right. How can I fix the nested list-group look?
Updated
In the Standard example above, I see spacing issues with the nested menu.
In the Flush example, the bottom line should be the same with in all cases, but the nested level should have a larger indentation.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您可以在下面使用自定义CSS来添加内部列表组的顶部和底部边距:
否则,您可以使用间距实用程序来添加 margin 。只需在内部列表组中添加
my-2
。You can use custom css below for add top and bottom margin of inner list group:
Otherwise, You can use spacing utilities for add margin. Just add
my-2
in inner list-group.