2

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.

1

4 Answers 4

1

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

Sign up to request clarification or add additional context in comments.

3 Comments

very nice! just what i needed.
@Joe This is not a good solution. ellipsis is an IE proprietary value for overflow, and doesn't work on any browser other than IE.
As the page I linked to states (and I have tested this), it works fine in Chrome, Safari, Opera(with '-o-text-overflow') and of course IE7+
0

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

Comments

0

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.

Comments

0

Hope this will be helpful

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

1 Comment

Not a very good solution - you still need to know how many characters till the text will overflow. Also, the jQuery code can be made much, much, more efficient with some caching.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.