我试图将文本"Zarzleud"对齐在我的卡片上方,但我try 的一切都不起作用.我已经try 了我能想到的一切方法,我是一个初学者,所以我仍在学习.我try 添加新的样式、列、显示等.

这是最近的修复try :

#zarzad {
  display: flex;
  flex-direction: column;
  align-items: center;
}

.container section {
  margin-top: 20px;
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
}

.card {
  width: 200px;
  margin-right: 10px;
  margin-bottom: 20px;
  border: 2px solid #eee;
  background-color: #333;
  color: #eee;
  box-sizing: border-box;
  border-radius: 10px;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

#zarzad h2 {
  width: 100%;
  text-align: center;
  margin-bottom: 20px;
}

.card img {
  width: 100%;
  border-radius: 10px 10px 0 0;
}

.card .info {
  padding: 15px;
}

.card h3,
.card p {
  margin: 0;
  color: #eee;
}
<section id="zarzad">
  <div class="container">
    <h2>Zarząd</h2>
    <div class="card">
      <img src="https://cdn.discordapp.com/avatars/637347195623833630/71891a4d1cd9795017d08953adb04cdb.png" alt="Zarząd 1">
      <div class="info">
        <h3>Bakłażan</h3>
        <p>Właściciel</p>
      </div>
    </div>
    <div class="card">
      <img src="https://cdn.discordapp.com/avatars/314066973879304203/4207e8071ce2f216fac7d188e17a8502.png" alt="Zarząd 1">
      <div class="info">
        <h3>Templariusz</h3>
        <p>Zarząd</p>
      </div>
    </div>
  </div>
</section>

This is how it should look

推荐答案

您需要将卡片放入与<h2>个文本分开的另一个容器中. 然后把它变成flexbox.

请参阅这个例子:

#zarzad {
  display: flex;
  flex-direction: column;
  align-items: center;
}

.container section {
  margin-top: 20px;
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
}

.card-container {
  display: flex;
}

.card {
  width: 200px;
  margin-right: 10px;
  margin-bottom: 20px;
  border: 2px solid #eee;
  background-color: #333;
  color: #eee;
  box-sizing: border-box;
  border-radius: 10px;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

#zarzad h2 {
  width: 100%;
  text-align: center;
  margin-bottom: 20px;
}

.card img {
  width: 100%;
  border-radius: 10px 10px 0 0;
}

.card .info {
  padding: 15px;
}

.card h3,
.card p {
  margin: 0;
  color: #eee;
}
<section id="zarzad">
  <div class="container">
    <h2>Zarząd</h2>

    <div class="card-container">
      <div class="card">
        <img src="https://cdn.discordapp.com/avatars/637347195623833630/71891a4d1cd9795017d08953adb04cdb.png" alt="Zarząd 1">
        <div class="info">
          <h3>Bakłażan</h3>
          <p>Właściciel</p>
        </div>
      </div>
      <div class="card">
        <img src="https://cdn.discordapp.com/avatars/314066973879304203/4207e8071ce2f216fac7d188e17a8502.png" alt="Zarząd 1">
        <div class="info">
          <h3>Templariusz</h3>
          <p>Zarząd</p>
        </div>
      </div>
    </div>
  </div>
</section>

Html相关问答推荐

HTML CSS如何使用图像作为中心点将元素置于中心

如何在一个div中心字体图标?

纯CSS语音气泡与半透明背景和边框

将ANGLE模板高效地迁移到ANGLE 17中引入的新语法

垂直页眉,每行只显示一个使用css的字母

Div中的图像问题-(TailWind CSS中的网格)

在Hero部分中同时zoom 背景图像和形状的问题

如何在R rmarkdown中创建循环中的分页表?

如何防止滑动滚动元素时touch 屏出现空白区域?

为什么我的 html 对话框在 React 中没有渲染在我的内容之上?

如何为Vuetify输入控件减小标签和字段之间的间距?

在React中如何处理HTML本地日期输入?

Flex布局中,当父元素高度较高时,交叉轴上出现额外的空白问题.

如何配置 prettier 使其以 Vue.js 模板语法的特定方式运行?

有没有办法使用 CSS border-radius 创建 HTML 视频标签的三角形显示?

列宽等于最宽列宽度的无界容器

标题之间和之后的 Hr 线

两个按钮范围滑块的 CSS

根据正则表达式 attr 从 read_html 过滤表格

更改包含图标高度的 div