2013-04-24 44 views
0

我在遇到左浮动跨度和右浮动跨度之间存在省略号文本(.title)时遇到问题。发生溢出时,将长度下推至新行。我怎样才能解决这个问题?文本溢出省略号,在浮动左跨度和浮动右跨度之间的跨度

JS FIDDLE: http://jsfiddle.net/VfHdS/6/

HTML:

<div class="song"> 
<span class="tracknumber">4</span> 
<div class="title">This is the song tittle!!!!!!!!!!!</div> 
<span class="length">4:31</span> 
</div> 

CSS:

.song { 
    font-size: 14px; 
    padding: 2px 20px; 
} 
.tracknumber { 
    margin-right: 10px; 
} 
.title { 
    color: #262626; 
    display:inline-block; 
    white-space: nowrap; 
    overflow: hidden; 
    text-overflow: ellipsis; 
} 
.length { 
    float: right; 
} 
+0

'文本溢出:省略号;'工作,只有块的容器。阅读更多在[W3](http://dev.w3.org/csswg/css-ui/#text-overflow0) – 2013-04-24 01:13:11

+0

仍然没有运气http://jsfiddle.net/VfHdS/6/。 – user1508287 2013-04-24 01:27:06

+0

@Sonu Joshi:内联块也是块容器。 – BoltClock 2013-04-24 01:37:53

回答

1

使用你提供我成立了一个小提琴样本HTML。设置.title元素显示块是显示椭圆的原因。

http://jsfiddle.net/f4uUJ/

我也重新定位的磁道数和播放时间绝对好使的歌名可以是100%的宽度。您只需在轨道上添加填充以使标题具有一定的呼吸空间。

CSS

.song { 
    font-size: 14px; 
    padding: 2px 40px 2px 20px; 
    position:relative; 
} 
.tracknumber { 
    position:absolute; 
    left:0; 
    top:2px; 
} 
.title { 
    white-space: nowrap; 
    width: 100%; 
    display:block; 
    overflow: hidden; 
    text-overflow:ellipsis; 
} 
.length { 
    position:absolute; 
    right:0; 
    top:2px; 
} 
+0

非常感谢。 – user1508287 2013-04-24 02:04:08