【问题标题】:why the elements are not getting spaced?为什么元素没有间隔?
【发布时间】:2020-03-20 17:02:55
【问题描述】:

嘿,我希望借助导航栏中的引导程序在网站中分隔 3 个 div,但我没有得到想要的结果 我希望 DIV 像这样,请帮助我用引导类解决它

<content of div1> <content of div2> <content of div3>

<link href="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css" rel="stylesheet" />

<nav class="navbar navbar-expand-sm navbar-light bg-light d-flex justify-content-between  ">
  <div>// div 1//
  </div>
  <div class="collapse navbar-collapse " id="navbarSupportedContent">// div 2//
  </div>
  <div>// div 3//
  </div>
</nav>

【问题讨论】:

  • 这是因为您的 HTML 中有错字。你有&lt;nav clss 而不是&lt;nav class
  • 你不需要把整个内容都放上去,下次你会被否决。只需提出相关内容的问题 - 这将为您的答案提供解决方案。
  • 由于您更新了代码以修复错字,只需删除第二个 div 上的 flex-grow: 1

标签: css bootcamp


【解决方案1】:

默认情况下,.navbar-collapse 设置为 flex-grow:1。你需要禁用它才能得到你想要的:

<link href="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css" rel="stylesheet" />

<nav class="navbar navbar-expand-sm navbar-light bg-light d-flex justify-content-between  ">
  <div>// div 1//
  </div>
  <div class="collapse navbar-collapse flex-grow-0" id="navbarSupportedContent">// div 2//
  </div>
  <div>// div 3//
  </div>
</nav>

【讨论】:

    猜你喜欢
    • 2013-01-01
    • 1970-01-01
    • 2019-12-05
    • 2023-01-02
    • 2023-01-31
    • 2015-05-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多