Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Trim overflow text in css? [duplicate]

Tags:

html

css

trim

Is it possible to trim the ending of the text?

INPUT

this is an extremely very long text

RESULT

this is an ...

like image 226
001 Avatar asked Mar 31 '13 10:03

001


2 Answers

Yes, that is possible to achieve solely by CSS.

See my Example on jsFiddle

Key for achieving the effect is to use a combination of the following CSS-properties:

width: [x]px
overflow: hidden
white-space: nowrap
text-overflow: ellipsis

The width is neccessary to use overflow. Overflow is needed for text-overflow and white-space is needed to prevent breaks and to assure that the whole text is in one line.

like image 108
hurrtz Avatar answered Sep 23 '22 18:09

hurrtz


Maybe you can try

text-overflow:ellipsis;

http://davidwalsh.name/css-ellipsis

like image 37
ChoiZ Avatar answered Sep 26 '22 18:09

ChoiZ