我正在使用以下html,请参阅此jsfiddle
<div style="float: left;">
<div style="padding-left: 3px; padding-top: 3px;">
<div style="float: left;">
Title:
</div>
<div style="float: left; padding-left: 12px">
ABC
</div>
<div style="clear: both"></div>
</div>
<div style="padding-left: 3px; padding-top: 3px;">
<div style="float: left;">
Lyrics:
</div>
<div style="float: left; padding-left: 3px">
<div style="overflow: hidden; width: 180px">
ABC DEF GHI JKl MNO dsa dsa sddsa d s
</div>
<div style="overflow: hidden; width: 180px">
ABC DEF GHI JKl MNO MNO dsa dsa sddsa d s
</div>
</div>
<div style="clear: both"></div>
</div>
</div>
<div style="float: right; border-left: 1px solid black;">
<img src="http://cdn1.iconfinder.com/data/icons/snowish/72x72/actions/gtk-media-play-ltr.png">
</div>
</div>
但我的文字溢出并未隐藏。 当我使用小文本而不是&#39;
时ABC DEF GHI JKl MNO dsa dsa sddsa d s
&#39;一切都很好。
答案 0 :(得分:4)
white-space: nowrap
: <div style="float: left;">
<div style="padding-left: 3px; padding-top: 3px;">
<div style="float: left;">
Title:
</div>
<div style="float: left; padding-left: 12px">
ABC
</div>
<div style="clear: both"></div>
</div>
<div style="padding-left: 3px; padding-top: 3px;">
<div style="float: left;">
Lyrics:
</div>
<div style="float: left; padding-left: 3px">
<div style="overflow: hidden; white-space: nowrap; width: 180px; ">
ABC DEF GHI JKl MNO dsa dsa sddsa d s
</div>
<div style="overflow: hidden; white-space: nowrap; width: 180px">
ABC DEF GHI JKl MNO MNO dsa dsa sddsa d s
</div>
</div>
<div style="clear: both"></div>
</div>
</div>
<div style="float: right; border-left: 1px solid black;">
<img src="http://cdn1.iconfinder.com/data/icons/snowish/72x72/actions/gtk-media-play-ltr.png">
</div>
</div>
height
。答案 1 :(得分:1)
您需要指定一个高度,以便容器知道溢出的开始位置。