1
正如你所看到的,一个弹性盒子不会分成两部分,只是显示蓝色部分。如果您取消对overflow: hidden
的注释,它将按预期工作。 为什么?为什么flex layout受其溢出内容的影响?
.nav
内容超出了宽度。
.cont {
width: 200px;
height: 300px;
background-color: red;
display: flex;
}
.aside {
width: 50px;
height: 100%;
background-color: green;
}
.nav {
/*overflow: hidden;*/
flex: 1;
background-color: blue;
}
.info {
max-width: 70%;
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
word-wrap: normal;
}
.name {}
<div class="cont">
<div class="aside"></div>
<div class="nav">
<div class="info">
<span class="name"> tes te s dnaosdjw d adondnasjdoqnsnda djj</span>
</div>
</div>
</div>
THX,现在我知道为什么.aside元素萎缩的原因。另一个问题是,如果我从.nav元素中删除overflow:hidden。它的宽度将大于150px。它扩大!为什么? –
由于默认情况下Flex项目不能小于其内容。 Flex项目的初始大小为'min-width:auto'。你可以用'min-width:0'覆盖它:https://jsfiddle.net/eoy4saty/ –
http://stackoverflow.com/q/36247140/3597276 –