【问题标题】:Bootstrap 4.5 gridBootstrap 4.5 网格
【发布时间】:2020-08-25 01:00:23
【问题描述】:

我有一些奇怪的问题...我想创建某种网上商店。所以我有 1 行 4 列(4 个产品),我也使用 Bootstrap 4.5,这就是发生的事情: enter image description here

简单的问题图片放不下,但盒子之间的空间没有变小,为什么?我怎样才能调整这个盒子的大小?要更宽并在它们之间获得很小的空间?这是代码:

<section>
      <div class="container products">
          <div class="row justify-content-center">
            <div class="col-md-2 item">
                <img src="/img/product.png" alt="product">
            </div>
            <div class="col-md-2 offset-md-1 item">
                  
            </div>
            <div class="col-md-2 offset-md-1 item">
                  
            </div>
            <div class="col-md-2 offset-md-1 item">
                  
            </div>
          </div>
      </div>
  </section>

【问题讨论】:

  • 尝试将img-fluid类添加到图片中
  • 运行良好。谢谢,但现在我怎样才能让这个盒子更宽?太狭隘了……
  • col-md-2 正在设置 with。每行 12 列中的两列。所以你有四个 div,每个占据两列,剩下四个未使用的列。您可以尝试将col-md-2 更改为col-md-3
  • 好吧,我也这样做了。但是盒子之间没有空间......

标签: html css bootstrap-4


【解决方案1】:

尝试删除offset-md-1 类并为item 类添加边距。如果你想让区块更宽,请将col-md-2 更改为col-md-3

【讨论】:

    猜你喜欢
    • 2020-12-05
    • 2020-11-26
    • 2021-06-29
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2020-07-16
    • 2018-09-03
    • 2013-08-07
    相关资源
    最近更新 更多