Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/html/74.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 flexbox中的垂直中心问题_Html_Css_Flexbox - Fatal编程技术网

Html flexbox中的垂直中心问题

Html flexbox中的垂直中心问题,html,css,flexbox,Html,Css,Flexbox,我认为这是一个愚蠢的错误,但我不明白 .box{ 显示器:flex; 对齐项目:居中; 证明内容:中心; } 我认为增加身高可以解决你的问题 .box { display: flex; align-items: center; justify-content: center; height:100vh; } 我认为增加身高可以解决你的问题 .box { display: flex; align-items: center; justify-content: center; height:10

我认为这是一个愚蠢的错误,但我不明白

.box{
显示器:flex;
对齐项目:居中;
证明内容:中心;
}

我认为增加身高可以解决你的问题

.box {
display: flex;
align-items: center;
justify-content: center;
height:100vh;
}

我认为增加身高可以解决你的问题

.box {
display: flex;
align-items: center;
justify-content: center;
height:100vh;
}

如果这就是您的全部代码,那么您忘记了CSS:

.box div {
  width: 100px;
  height: 100px;
}
此外,尝试添加其他人建议的最大垂直高度

height: 100vh;

如果这就是您的全部代码,那么您忘记了CSS:

.box div {
  width: 100px;
  height: 100px;
}
此外,尝试添加其他人建议的最大垂直高度

height: 100vh;

你忘了为中间div(
.box div
)设置样式了,是吗?我不明白flex中CSS的“设置样式”。csad height 100vhA div只和它的内容一样大。使用.box div图像不居中你忘了为中间div设置样式(
.box div
),是吗?我不懂“设置样式”flex.csad height 100vh中的CSS div仅与其内容一样大。with.box div图像不居中Hank,这很好,但为什么MDN上没有“height:100vh”,但居中的字体是“align items:center”否@AdriDev MDN示例具有
.box{height:300px;}
.o0 ok但100vh不是完美的中心,没有完美的数字中心100vh占据视口的完整高度并对齐项目:中心使内容垂直居中。。我不明白,如果它不是完美的中心?谢谢,这很好,但为什么在MDN上没有“高度:100vh”,但中心的字体是“对齐项目:中心”不@AdriDev MDN示例具有
.box{height:300px;}
.o0 ok但100vh不是完美的中心,没有完美的数字中心100vh占据视口的完整高度并对齐项目:中心使内容垂直居中。。我不明白,如果它不是完美的中心?