2014-06-24 33 views

回答

0

不是很确定你想要达到什么,但这不是Flexbox布局的工作方式。要在元素上使用'flex'属性,它需要位于具有'display:flex'属性的父元素中。

<style> 
    #flexContainer { 
     display: flex; 
    } 
    #item1 { 
     width: 50px; 
     background: #66CC33; 
     flex: 1; 
    } 
    #item2 { 
     width: 50px; 
     background: #0099FF; 
     flex: 5; 
    } 
    #item3 { 
     width: 50px; 
     background: #66CC33; 
     flex: 10; 
    } 
</style> 

<html> 
    <div id="flexContainer"> 
     <div id="item1">1</div> 
     <div id="item2">2</div> 
     <div id="item3">3</div> 
    </div> 
</html> 
3

这是因为您使用min-height<body>得到充分的高度。对于Internet Explorer,您需要使用height属性(使用100%100vh)。

10

如果有人正在尝试这不是身体,但一些孩子div。 你可以设置高度:0;在具有最小高度的元素上。

IE只想要flex-grow auto元素的父元素上的任何高度。

因此,它可能看起来像这样:

.flex-parent{ 
    display: flex; 
    min-height: 300px; 
    height: 0; 
} 
.flex-child{ 
    flex: 1 1 auto; 
} 
+1

这不是一个好主意,如果你的块不再那么当前窗口高度 – brabertaser19

+0

高度:在固定这对我的父元素0。谢谢!!! – Ominus

相关问题