.container{display: flex;width: 120px;}
.box{flex:1;height:30px;background: red;margin: 3px;overflow: hidden;
text-overflow: ellipsis; white-space: nowrap;}
<div class="container">
<div class="box"></div>
<div class="box"></div>
<div class="box"></div>
</div>
一开始设置好好的,但是一添加文字就宽度就动态变化了,如何让他不变化,一直保持初始化的宽度
flex: 1 0;
你可以简单理解为第一个参数表示是否放大,第二个参数表示是否缩小。