<div class='box'>
<p class='text'>這是一段長文本這是一段長文本這是一段長文本<p>
<div class="icon"></div>
</div>.box { width: 175px;
}.icon { display: inline-block; width: 20px; height: 20px; background: red;
}預期效果:如果文本不夠長,不需要溢出,.icon元素緊跟在文本后;如果文本過長則溢出,.icon元素緊跟在...后不換行。需要兼容到ie9,求大神解答
2 回答

largeQ
TA貢獻2039條經(jīng)驗 獲得超8個贊
<div class='box'> <p class='text'>這是一段長文本這是一段長文本這是一段長文本<p> <div class="icon"></div></div>
.box { width: 175px; display: table; table-layout: fixed; border-collapse: collapse }p { display: table-cell; text-overflow: ellipsis; white-space: nowrap; overflow: hidden; }.icon { display: table-cell; width: 20px; height: 20px; background: red; }
希望對你有幫助
添加回答
舉報
0/150
提交
取消