gpt4 book ai didi

css - bootstrap 4 flex 行并排出现

转载 作者:行者123 更新时间:2023-11-28 14:54:20 24 4
gpt4 key购买 nike

我是 flex 的新手,我的老板希望我为此只使用 flexbox!问题是我试图让导航菜单显示在它自己的行中,但它一直环绕在搜索图标旁边,等等。我在代码中有它自己的行,所以我不知道为什么它并排出现

<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css" integrity="sha384-Gn5384xqQ1aoWXA+058RXPxPg6fy4IWvTNh0E263XmFcJlSAwiGgFAW/dAiS6JXm" crossorigin="anonymous">

<nav class="navbar navbar-expand-lg">
<div class="container">
<div class="d-flex flex-row w-100">
<div class="flex-column">
company logo here
</div>
<div class="flex-column">
<a class="navbar-brand" href="#">
company name here
</a>
</div>
<div class="flex-column justify-content-end">
search icon here
</div>
<div class="flex-column justify-content-end">
<button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#collapsibleNavbar">
<span class="navbar-toggler-icon"></span>
</button>
</div>
</div>
<div class="d-flex flex-row w-100">
<div class="flex-column justify-content-start">
<div class="collapse navbar-collapse" id="collapsibleNavbar">
<ul class="navbar-nav">
<li class="nav-item">
<a class="nav-link" href="#">Link</a>
</li>
<li class="nav-item">
<a class="nav-link" href="#">Link</a>
</li>
<li class="nav-item">
<a class="nav-link" href="#">Link</a>
</li>
</ul>
</div>
</div>
</div>
</div>
</nav>

<script src="https://code.jquery.com/jquery-3.2.1.slim.min.js" integrity="sha384-KJ3o2DKtIkvYIK3UENzmM7KCkRr/rE9/Qpg6aAZGJwFDMVNA/GpGFF93hXpG5KkN" crossorigin="anonymous"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.12.9/umd/popper.min.js" integrity="sha384-ApNbgh9B+Y1QKtv3Rn7W3mgPxhU9K/ScQsAP7hUibX39j7fakFPskvXusvfa0b4Q" crossorigin="anonymous"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/js/bootstrap.min.js" integrity="sha384-JZR6Spejh4U02d8jOt6vLEHfe/JQGiRRSQQxSfFWpi1MquVdAyjUar5+76PVCmYl" crossorigin="anonymous"></script>

最佳答案

你只需要添加一个 CSS 规则:

.navbar-expand-lg > .container {
flex-wrap:wrap
}

Fiddle

关于css - bootstrap 4 flex 行并排出现,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51234471/

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