我目前在容器内安排盒子的尝试已经产生了这个输出。
但我想要实现的是,
例如:第一行,这些应该是我每个之间只有1px的差距。或者采取最后一行,只有一个盒子,它应该覆盖容器的整个宽度。
此处的代码: http://codepen.io/anon/pen/rbkdh
此处的代码仅供参考:
HTML
<ul class="flex-container">
<li class="flex-item">1, One One One</li>
<li class="flex-item">2, Two Two</li>
<li class="flex-item">3, Three</li>
<li class="flex-item">4, Four Four Four Four Four</li>
<li class="flex-item">5, Five Five</li>
<li class="flex-item">6, Six</li>
</ul>
CSS
.flex-container {
padding: 0;
margin: 0;
list-style: none;
border: 1px solid;
display: -webkit-box;
display: -moz-box;
display: -ms-flexbox;
display: -webkit-flex;
display: flex;
flex-direction: row;
flex-wrap: wrap;
-webkit-flex-flow: row wrap;
justify-content: space-between;
align-items: stretch;
align-content: stretch;
max-width:400px; /*only width is fixed*/
}
.flex-item {
background: green;
padding-top: 10px;
padding-bottom: 10px;
padding-left: 15px;
padding-right: 15px;
margin: 2px;
line-height: 2em;
color: white;
font-weight: bold;
font-size: 1em;
text-align: center;
flex-grow:1;
}
答案 0 :(得分:1)