css 如何使卡片中的所有按钮都处于同一高度

bqf10yzr  于 12个月前  发布在  其他
关注(0)|答案(1)|浏览(98)

我想问如何使所有的按钮在不同的卡片,有不同长度的文字是在同一个地方。按钮应该在年底的卡片。This is what i want。这是我的HTML,CSS代码。

* {
  margin: 0px;
  padding: 0px;
  box-sizing: border-box;
  font-family: sans-serif;
}

body {
  background-color: #f0f0f0;
}

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

.card {
  width: 325px;
  background-color: #f0f0f0;
  border-radius: 8px;
  overflow: hidden;
  box-shadow: 0px 2px 4px rgba(0, 0, 0, 0.2);
  margin: 20px;
}

.card img {
  width: 100%;
  height: auto;
}

.card-content {
  padding: 16px;
}

.card-content h3 {
  font-size: 28px;
  margin-bottom: 8px;
}

.card-content p {
  color: #666;
  font-size: 15px;
  line-height: 1.3;
}

.card-content .btn {
  display: inline-block;
  padding: 8px 16px;
  background-color: #333;
  text-decoration: none;
  border-radius: 4px;
  margin-top: 16px;
  color: #fff;
}

个字符

11dmarpk

11dmarpk1#

这个就可以了
扩展代码段并运行代码以在宽屏幕上查看

* {
      margin: 0px;
      padding: 0px;
      box-sizing: border-box;
      font-family: sans-serif;
    }

    body {
      background-color: #f0f0f0;
    }

    .card-container {
      display: flex;
      justify-content: center;
      flex-wrap: wrap;
      margin-top: 100px;
      align-items: stretch; 
    }

    .card {
      display: flex; 
      flex-direction: column; 
      width: 325px;
      background-color: #f0f0f0;
      border-radius: 8px;
      overflow: hidden;
      box-shadow: 0px 2px 4px rgba(0, 0, 0, 0.2);
      margin: 20px;
    }

    .card img {
      width: 100%;
      height: auto;
    }

    .card-content {
      display: flex;
      flex-direction: column;
      justify-content: space-between; 
      padding: 16px;
      height: 100%; 
    }

    .card-content h3 {
      font-size: 28px;
      margin-bottom: 8px;
    }

    .card-content p {
      color: #666;
      font-size: 15px;
      line-height: 1.3;
    }

    .card-content .btn {
      display: inline-block;
      padding: 8px 16px;
      background-color: #333;
      text-decoration: none;
      border-radius: 4px;
      color: #fff;
    }

个字符

相关问题