I have a parent and two main children. The first child has two elements with fixed width and height. The second child has some text and when I resize text is shown or hidden in response to page size. But when I resize at a certain point the two elements of the first child insted of staying inline they go one above the other. How can I prevent this?

所以在第二张图片中,两个元素是一个在另一个之上,我不想要这个。
小提琴:jsfiddle
html
<div class="parent-div">
<div class="icon-div">
<div>a</div>
<div>a</div>
</div>
<div class="text-div">This is text I'd like to truncate when space doesn't permit</div>
</div>
Run Code Online (Sandbox Code Playgroud)
css
.parent-div {
display: -webkit-flex;
display: -moz-flex;
display: flex;
}
.text-div {
white-space: nowrap;
overflow: hidden;
text-overflow: hidden;
min-width: 0;
}
.icon-div {
-webkit-flex: 1;
-moz-flex: 1;
flex: 1;
}
.icon-div div {
display:inline-block;
border: 1px solid #ccc;
width:40px;
height:40px;
}
Run Code Online (Sandbox Code Playgroud)
不要让你的.icon-div缩水 ( flex: 1 0 auto);
.icon-div {
flex: 1 0 auto;
}
Run Code Online (Sandbox Code Playgroud)
设置:white-space:nowrap有一个不幸的副作用,text-div就是icon-div当屏幕变得太小时,文本会跑到占用的空间中。