【问题标题】:Bootstrap v5.0 d-flex in navbar not working导航栏中的 Bootstrap v5.0 d-flex 不起作用
【发布时间】:2022-01-24 04:22:00
【问题描述】:

这里我在 a 和 div 的父标签中给出了 d-flex 和 justify-content-between 类。但我不明白为什么它不能在这里工作..

<nav class="navbar navbar-expand-lg navbar-light bg-light">
          <div class="container d-flex justify-content-between">
            <a class="navbar-brand" href="#">
              <img width="100%" height="50" src="icons/Logo.png">
            </a>
            <div class="collapse navbar-collapse" id="navbarScroll">
              <h1>Right</h2>
            </div>
          </div>
    </nav>

【问题讨论】:

    标签: css flexbox bootstrap-5


    【解决方案1】:

    因此,使用您提供的代码,您只需将justify-content: flex-end 添加到.navbar-collapse 部分。

    要完成您提供的代码示例,您只需将引导类 justify-content-end 添加到右侧第二个位置,如下所示

    <div class="container d-flex justify-content-between">
        <a class="navbar-brand" href="#">
            <img width="100%" height="50" src="icons/Logo.png">
        </a>
        <div class="collapse navbar-collapse justify-content-end" id="navbarScroll">
            <h1>Right</h1>
        </div>
    </div>
    

    显示在this codepen

    【讨论】:

    • 还是不行
    • @JNJonyHossain 我将您提供的相同代码放入代码笔中,除了我的更改,您可以找到codepen here
    猜你喜欢
    • 2021-06-23
    • 2018-06-18
    • 1970-01-01
    • 2018-01-19
    • 2015-11-14
    • 2020-09-01
    • 1970-01-01
    • 2017-08-31
    • 1970-01-01
    相关资源
    最近更新 更多