0
我正在使用以下HTML和CSS。我刚刚熟悉Flex箱,跟着this tutorial到中心(包括水平,垂直)的一些其他HTML元素:柔性盒垂直居中不起作用
<div>
<div class="page-center">
<div id="target_div">
<h2 class="text-center">Connecting to the server</h2>
<div class="progress">
<div class="progress-bar progress-bar-striped active" style {{width: '100%'}}></div>
</div>
</div>
</div>
</div>
.page-center {
display: flex;
align-items: center;
justify-content: center;
max-height: 100%;
}
内target_div
元素水平,但不垂直居中。 任何想法为什么这不起作用?
我认为你应该包含'* {margin:0; padding0}',这样它会移除滚动条 - 更容易看到结果 –
将这些添加到codepen。谢谢。 – bransonl
它仍然不起作用: http://ariansnake.herokuapp.com/ https://bitbucket.org/arianhosseinzadeh/snakegame –