如果没有足够的空间,如何使Bootstrap卡垂直对齐?

eyh26e7m  于 2023-04-09  发布在  Bootstrap
关注(0)|答案(1)|浏览(167)

Here is the picture of the website.
我想让我的牌在水平方向没有空间时垂直对齐。
当我添加另一张卡片时,整个网站就乱了套👇🏽。
Image of website
我期望卡下去,因为我使用了一些代码,这将有助于。

Bootstrap- d-flex mt-4 me-5

HTML-第g-3行

HTML- col-12 col-md-6 col-lg-4

Bootstrap-容器

r3i60tvu

r3i60tvu1#

要在水平方向没有空间时使您的卡片垂直对齐,并确保即使添加另一张卡片时站点仍保持原位,您可以使用Bootstrap的flexbox实用程序沿着适当的HTML结构。下面是一个示例:
HTML:

<div class="container">
  <div class="row g-3">
    <div class="col-12 col-md-6 col-lg-4">
      <!-- Card 1 -->
    </div>
    <div class="col-12 col-md-6 col-lg-4">
      <!-- Card 2 -->
    </div>
    <div class="col-12 col-md-6 col-lg-4">
      <!-- Card 3 -->
    </div>
    <!-- Add more cards as needed -->
  </div>
</div>

CSS(Bootstrap flexbox实用程序):

.row.g-3 {
  display: flex;
  flex-wrap: wrap;
}

相关问题