相关代码
问题描述
info div 内容是动态变化的溢出省略号不能换行
几个 button 的宽度都是动态变化的(query, more, search)
期待的结果是:
不用 JS 的情况下
info 内容动态变化 但是加上左右两个 button 的宽度不会溢出父容器
红色框的宽度随子元素内容加宽但是加上 search 的宽度不会超过 container 宽度
more button 始终跟在 info 后面
实际看到的错误信息是:
info 内容多的情况溢出了 container
info div 内容是动态变化的溢出省略号不能换行
几个 button 的宽度都是动态变化的(query, more, search)
不用 JS 的情况下
info 内容动态变化 但是加上左右两个 button 的宽度不会溢出父容器
红色框的宽度随子元素内容加宽但是加上 search 的宽度不会超过 container 宽度
more button 始终跟在 info 后面
info 内容多的情况溢出了 container
.container {
display: flex;
border: 1px solid;
justify-content: space-between;
margin: auto;
width: 600px;
padding: 10px;
}
.left {
flex:1;
border: 1px solid red;
display: flex;
align-items: center;
padding: 5px;
}
.search {
width: 60px;
margin-left: 10px;
}
.query {
width:60px;
color: blue;
}
.info {
flex:1;
max-width:360px;
margin-left: 10px;
overflow: hidden;
text-overflow: ellipsis;
word-break: keep-all;
white-space: nowrap;
}
.more {
margin-left: 10px;
color: red;
width:60px;
}
.btn {
border: 1px solid green;
padding: 5px;
border-radius: 2px;
}
改一下css部分,效果:
3 回答1.4k 阅读✓ 已解决
4 回答1.4k 阅读✓ 已解决
2 回答1k 阅读✓ 已解决
2 回答1.4k 阅读✓ 已解决
4 回答1.5k 阅读
2 回答1.2k 阅读✓ 已解决
1 回答1.2k 阅读✓ 已解决
.container的宽度不要固定,由子元素撑开即可: