Joe
Joe

Reputation: 3119

css - hiding overflow

Is it possible to hide the overflow of the text in say a fixed width div and replace it with "..."? It obviously looks ugly if the text is just cut off, I really need to be able to show a ... in these cases.

Upvotes: 2

Views: 374

Answers (4)

Raghu Kumara Chari
Raghu Kumara Chari

Reputation: 166

Hope this will be helpful

$('#customComboBox').text(($.trim($('#customComboBox').text()).length > 19) ? 
    $.trim($('#customComboBox').text()).substring(0, 16) + '...' : 
    $.trim($('#customComboBox').text()));

Upvotes: 0

KarmicMind
KarmicMind

Reputation: 166

You can do it with text-overflow: ellipsis;, but it doesn't seem to work in IE6 and Firefox..

http://www.quirksmode.org/css/textoverflow.html

Upvotes: 1

fredley
fredley

Reputation: 33941

You cannot do this with css. You'll have to do it with PHP or Javascript. Here's a decent tutorial on doing it with JS.

Upvotes: 0

Ciprian Tepes
Ciprian Tepes

Reputation: 866

I'm not sure if you can do that only with CSS, you have to use either javascript or php.

Upvotes: 0

Related Questions