Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/css/33.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Html 使div在行中的高度相等,并使文本垂直居中与Flexbox对齐_Html_Css_Flexbox - Fatal编程技术网

Html 使div在行中的高度相等,并使文本垂直居中与Flexbox对齐

Html 使div在行中的高度相等,并使文本垂直居中与Flexbox对齐,html,css,flexbox,Html,Css,Flexbox,如何确保每张卡片高度相等,同时保持文本垂直居中 我已经包含了一个JSFIDLE链接来说明这个问题 HTML JSFIDLE 您需要删除以下行: align-items: center; 并添加以下内容: justify-content:center; .homepage__recent-story{ background-color: red; margin: 0 0 0 0; padding: 42px; border-top: 1px solid grey; over

如何确保每张卡片高度相等,同时保持文本垂直居中

我已经包含了一个JSFIDLE链接来说明这个问题

HTML JSFIDLE
您需要删除以下行:

align-items: center;
并添加以下内容:

justify-content:center;
.homepage__recent-story{
  background-color: red;
  margin: 0 0 0 0;
  padding: 42px;
  border-top: 1px solid grey;
  overflow-y: auto;
  overflow-x: scroll;
  display: flex;
  flex-wrap: nowrap;
  /* align-items: center; <--- removed */
}

.recent-story__card{
  display: flex;
  flex-direction: column;
  flex: 1;
  background-color: white;
  border-radius: 4px;
  padding: 24px;
  box-sizing: border-box;
  max-width: 300px;
  min-width: 300px;
  color: black;
  box-shadow: 0 0 12px rgba(0,0,0,.03);
  justify-content:center; /* Added */
}
您的课程应如下所示:

justify-content:center;
.homepage__recent-story{
  background-color: red;
  margin: 0 0 0 0;
  padding: 42px;
  border-top: 1px solid grey;
  overflow-y: auto;
  overflow-x: scroll;
  display: flex;
  flex-wrap: nowrap;
  /* align-items: center; <--- removed */
}

.recent-story__card{
  display: flex;
  flex-direction: column;
  flex: 1;
  background-color: white;
  border-radius: 4px;
  padding: 24px;
  box-sizing: border-box;
  max-width: 300px;
  min-width: 300px;
  color: black;
  box-shadow: 0 0 12px rgba(0,0,0,.03);
  justify-content:center; /* Added */
}
.homepage\uu最新报道{
背景色:红色;
保证金:0;
填充:42px;
边框顶部:1px纯色灰色;
溢出y:自动;
溢出-x:滚动;
显示器:flex;
柔性包装:nowrap;
/*对齐项目:居中;