html - 图像不在较大的卡片 div 中居中

标签 html css bootstrap-4

图像不会在我的卡片上居中。如果我将容器变小,它们在 PC 上看起来很好(居中),但在响应时它们会恢复到更大的尺寸并保持对齐。无论容器大小如何,我都希望卡片容器中的图像居中。

我已经尝试将 display:inline-block 更改为 display:block 和 class="text center"以及 .mx-auto,但似乎没有任何效果。这是整个页面的链接 http://www.wisbechinlinespeed.co.uk/committee-test.htm

.row .heading .heading-icon {
  display: block;
}

.committee-card .card:hover {
  box-shadow: 0px 0px 10px rgba(0, 0, 0, 0.3);
  border: 0;
}

.committee-card .card {
  float: left;
  width: 100%;
  background: #fff;
  padding: 30px 20px;
  text-align: center;
  border: 2px solid #d5d5d5;
  margin: 0 0 28px;
}

.committee-card .card figure {
  width: 148px;
  height: 148px;
  border-radius: 100%;
  display: inline-block;
  margin-bottom: 15px;
}

.committee-card .card img {
  width: 148px;
  height: 148px;
  border-radius: 100%;
  display: inline-block;
}
<section class="committee-card padding-lg">
  <div class="containera">
<ul class="row">
  <li class="col-12 col-md-6 col-lg-3">
    <div class="card equal-height" style="height: 349px;">
      <figure>
        <img src="committee/001.jpg" class="img-responsive" alt="" />
      </figure>

      <h1>Richard Garwell</h1>
      <br />
      <p>Trustee and Track Committee Member</p>
    </div>
  </li>

  <li class="col-12 col-md-6 col-lg-3">
    <div class="card equal-height" style="height: 349px;">
      <figure>
        <img src="committee/002.jpg" class="img-responsive" alt="" />
      </figure>

      <h1>Glen Brown</h1>
      <br />
      <p>Trustee and Chairman</p>
    </div>
  </li>

  <li class="col-12 col-md-6 col-lg-3">
    <div class="card equal-height" style="height: 349px;">
      <figure>
        <img src="committee/003.jpg" class="img-responsive" alt="" />
      </figure>
    </div>
  </li>
</ul>
  </div>
</section>

最佳答案

stackoverflow 说我不允许发布图片,所以你必须点击下面的链接查看说明

这是你想要的吗?

enter image description here

我在你的代码中看到了 flexbox:

enter image description here

那么,为什么不直接将 align-items: center; 添加到整个容器。

enter image description here

关于html - 图像不在较大的卡片 div 中居中,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54491854/

相关文章:

html - Bootstrap - NavBar 没有很好地折叠第一个元素

css - 如何在元素并排而不是堆叠时在元素之间添加边距? [ Bootstrap ]

javascript - 如何调整从其他用户加载的图像的大小,以便在保持尺寸的同时使用 css 设置最大宽度和高度? (HTML/JS/CSS)

javascript - 如何将类应用于字符串中指定的字符组?

bootstrap-4 - Bootstrap 4 向 div 添加滚动条

javascript - JavaScript 中 float 和非空的验证

javascript - 我试图将此代码分成单独的文件

javascript - Bootstrap 3 单选按钮双切换

jquery - 导航栏超出页面宽度

javascript - 执行 window.print 时的边距和填充问题