【问题标题】:HTML - Center cardsHTML - 中心卡片
【发布时间】:2021-03-03 16:21:17
【问题描述】:

我有一个小问题。我不知道如何居中 (img) 卡片。我尝试了很多代码,但没有任何反应。

【问题讨论】:

标签: html center


【解决方案1】:

您想如何使它们居中?一种选择是使用弹性盒子。给出 .flex-container 的父元素类并执行以下操作:

.flex-container {
  display: flex;
  justify-content: center;
}

【讨论】:

    【解决方案2】:

    我最常用的是:

    
    .card-container {
        display: grid;
        place-items: center;
    }
    
    

    这会将 .card-container 中的所有项目放在中间。

    【讨论】:

      【解决方案3】:

      如果您需要在行中居中,请在 <div class="row ..."> 中添加这样的 css

      .justify-content-center {
      -webkit-box-pack: center !important;
          -ms-flex-pack: center !important;
              justify-content: center !important;
      }
      

      【讨论】:

        猜你喜欢
        • 2020-09-10
        • 2021-06-13
        • 2023-03-16
        • 2017-07-27
        • 2021-08-27
        • 1970-01-01
        • 1970-01-01
        • 2022-01-10
        • 2020-01-27
        相关资源
        最近更新 更多