Priyanka
Priyanka

Reputation: 2832

How to show the text overflow after showing two lines in the div using css?

I'm designing a web page. I want to show the text overflow with the help of ellipsis to the div. But I want to show the two lines of data in the div and after that I want to handle the text overflow. I don't want to set the fix height to the div. How to do this using css?

Upvotes: 0

Views: 300

Answers (1)

Purag
Purag

Reputation: 17061

Fortunately, CSS3 added a text-overflow property. The most this can do, though, is truncate text (and show the rest on hover, but you probably want a click function).

element {
    text-overflow: ellipsis; // exactly what you wanted
}

Examples and docs.

text-overflow is not in the current version of the CSS3 spec. Bummer.

I recommend doing this with javascript or jQuery.

Upvotes: 1

Related Questions