2013-07-09 26 views

回答

3

在標準Flexbox的草案,單個撓曲項可以是垂直和水平中心的通過使用margin: auto。你要使用的,而不是對齊項屬性如下:

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 */ 
} 
+0

太棒了,謝謝! – wilsonpage

1

嘗試設置在柔性項目的下列:

align-self: flex-start; 
+0

這將意味着該項目是*始終*頂端對齊。我希望物品集中排列,除非物品比父容器高。 – wilsonpage