我有一个flexbox,里面只有一件东西。此项目在水平和垂直方向居中。当项比它的容器长得高时,它在容器的顶部和底部同样地溢出。我希望它只在底部溢出,并在顶部锚定。有什么想法吗?
http://codepen.io/wilsonpage/pen/LzryK (在Chrome Canary中查看最新的Flexbox)
发布于 2013-07-09 22:51:07
在标准的Flexbox草案下,通过使用margin: auto,单个flex项目可以垂直和水平居中。您将希望使用此属性,而不是align-items属性:
http://codepen.io/cimmanon/pen/EJdvn
section {
display: flex;
justify-content: center; /* you can remove this here, but its not hurting anything */
/* remove align-items */
height: 80%;
margin: 5% 0;
background: green;
}
div {
margin: auto; /* add */
}发布于 2013-07-09 19:35:39
尝试在flex项上设置以下内容:
align-self: flex-start;https://stackoverflow.com/questions/17547063
复制相似问题