父元素使用flex子元素width失效?
<div style="width:100px;">
<div class="box">
<div class="status"></div>
<div class="text">天津饭饭天津饭饭</div>
<button class="btn">测试</button>
</div>
</div>
.box{
display: flex;
align-items: center;
}
.status{
width: 8px;
height: 8px;
border-radius: 50%;
margin-right: 5px;
background-color: rgb(209, 48, 15);
}
.text{
flex: 1;
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
font-size: 12px;
}
.btn{
transform: scale(.6);
}
demo: https://jsfiddle.net/uxc68jop/同样的代码在demo中没有问题,在项目中第一个元素width就失效了?
回复
1个回答

test
2024-08-11
回复

适合作为回答的
- 经过验证的有效解决办法
- 自己的经验指引,对解决问题有帮助
- 遵循 Markdown 语法排版,代码语义正确
不该作为回答的
- 询问内容细节或回复楼层
- 与题目无关的内容
- “赞”“顶”“同问”“看手册”“解决了没”等毫无意义的内容