1.右側文字是多少就是多寬,左側默認佔據剩餘的全部空間。
flex
2.右側文字是多少就是多寬,和1同樣。左側文字很長很長溢出省略。
spa
3.左側文字和2同樣,右側文字給他加了兩個right。
設計
.footer { width: 300px; height: 20px; display: flex; overflow: hidden; } .left { background: #3cc8b4; flex: 1 1 auto; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 50px; } .right { background: #9bc; max-width: 250px; } .right-ellipsis { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; } <div class="footer"> <div class="left"> leftleftleftleftleftleftleftleftleftleftleftleftleft </div> <div class="right"> <div class="right-ellipsis"> rightrightrightrightrightrightrightrightright </div> </div> </div>