【发布时间】:2014-07-24 20:48:06
【问题描述】:
为什么我的容器没有垂直和水平居中对齐。
<div class="flex-container">
<header></header>
<article></article>
<aside></aside>
<footer></footer>
</div>
CSS
.flex-container {
display: flex;
flex-flow: row;
align-items: center;
justify-center: center;
}
.flex-container > * {
min-width: 100px;
min-height: 100px;
}
header {
background: rgba(200, 200, 200, 1);
}
article {
background: rgba(200, 200, 200, .8);
}
aside {
background: rgba(200, 200, 200, .6);
}
footer {
background: rgba(200, 200, 200, .4);
}
下面是相同的小提琴。 http://codepen.io/anon/pen/bAayc
【问题讨论】:
-
你做了什么使它居中?
-
@Paulie_D:你看到我的代码笔了吗……上面写着 algin-items 和 justify-center to center。
-
对齐内容...您仍然需要将容器居中。
-
应该对齐-center: center;不做这份工作....
-
容器为 100% 宽且居中。