2016-01-21 44 views
1

我想阻止绿格(.c)被按下时,容器外。格被推下来Flexbox的

http://codepen.io/anon/pen/vLpPRM?editors=1100

<section> 
<div class="a">aaaaaaaa</div> 
<div class="b">bbbbb</div> 
<div class="c">ccccccccc</div> 
</section> 

section 
    display: flex 
    flex-wrap: wrap 
    width: 500px 
    height: 200px 
    background-color: peru 

.a 
    width: 400px 
    height: 100px 
    background-color: gray 
.b 
    width: 100px 
    height: 200px 
    background-color: tan 

.c 
    background-color: green 
    height: 100px 
    width: 300px 
+0

可能重复:http://stackoverflow.com/questions/20977390/set-flexbox-children-to - 不同高度的可用空间 – chinaowl

+1

只需将'flex-wrap'属性更改为'no-wrap' – Ferrrmolina

回答

1

section { 
    flex-wrap: no-wrap 
} 

section { 
 
    display: flex; 
 
    flex-wrap: no-wrap; 
 
    width: 500px; 
 
    height: 200px; 
 
    background-color: peru; 
 
} 
 

 
.a { 
 
    width: 400px; 
 
    height: 100px; 
 
    background-color: gray; 
 
} 
 

 
.b { 
 
    width: 100px; 
 
    height: 200px; 
 
    background-color: tan; 
 
} 
 

 
.c { 
 
    background-color: green; 
 
    height: 100px; 
 
    width: 300px; 
 
}
<section> 
 
<div class="a">aaaaaaaa</div> 
 
<div class="b">bbbbb</div> 
 
<div class="c">ccccccccc</div> 
 
</section>