Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/css/37.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 弹性盒对齐顶部和顶部;居中对齐_Html_Css_Flexbox - Fatal编程技术网

Html 弹性盒对齐顶部和顶部;居中对齐

Html 弹性盒对齐顶部和顶部;居中对齐,html,css,flexbox,Html,Css,Flexbox,我有一面旗帜 横幅上有一段需要放在顶部的内容 然后它有一些标题文本,标题文本需要居中对齐 我很难把所有的东西都对准顶部和中心 .home横幅{ 填充顶部:0; 填充底部:0; 文本对齐:居中; 背景图片:url(../img/banners/banner home.jpg); 背景重复:无重复; 背景位置:右; 背景尺寸:封面; 边缘顶部:2米; 显示器:flex; 对齐项目:居中; 证明内容:中心; } .banner区域{} .横幅项目{ 弹性:1; } .横幅项目-顶部{ 自我校准:灵活

我有一面旗帜

横幅上有一段需要放在顶部的内容

然后它有一些标题文本,标题文本需要居中对齐

我很难把所有的东西都对准顶部和中心

.home横幅{
填充顶部:0;
填充底部:0;
文本对齐:居中;
背景图片:url(../img/banners/banner home.jpg);
背景重复:无重复;
背景位置:右;
背景尺寸:封面;
边缘顶部:2米;
显示器:flex;
对齐项目:居中;
证明内容:中心;
}
.banner区域{}
.横幅项目{
弹性:1;
}
.横幅项目-顶部{
自我校准:灵活启动;
}
.banner中心{}
.横幅标题{
颜色:@白色;
背景:@暗;
显示:内联块;
边缘底部:0.2米;
填充:1em;
}
.banner-title\u文本{
字体系列:@fatfrank;
文本转换:大写;
字体大小:60px;
字号:600;
}

退役军人和技术候选人的永久和合同安置专家

找到你的 完美的平民生涯
Flex属性适用于其子级。在您的例子中,容器有三个子容器,所以当您将flex属性应用到容器时,它会对齐它的子容器,但实际上您需要对齐子容器的子容器。所以您需要将flex属性重新应用于第三行的子级

Flex属性将相等维度与其所有子项对齐,直到指定为止。您需要对容器的所有子级应用一些高度,然后第三行的flex属性将起作用

.container {
  display: flex;
  flex-direction: column;
  justify-content: center;
}
.container > .banner-item {
  height: 10vh;
  display: flex;
  justify-content: center;
  flex-direction: column;
}
.container > .row:last-child {
  display: flex;
  flex-direction: column;
  height: 65vh;
  align-items: center;
  justify-content: center;
}
.container > .row:first-child {
  height: 15vh;
}

Flex属性应用于其子级。在您的例子中,容器有三个子容器,所以当您将flex属性应用到容器时,它会对齐它的子容器,但实际上您需要对齐子容器的子容器。所以您需要将flex属性重新应用于第三行的子级

Flex属性将相等维度与其所有子项对齐,直到指定为止。您需要对容器的所有子级应用一些高度,然后第三行的flex属性将起作用

.container {
  display: flex;
  flex-direction: column;
  justify-content: center;
}
.container > .banner-item {
  height: 10vh;
  display: flex;
  justify-content: center;
  flex-direction: column;
}
.container > .row:last-child {
  display: flex;
  flex-direction: column;
  height: 65vh;
  align-items: center;
  justify-content: center;
}
.container > .row:first-child {
  height: 15vh;
}
相关的-