10

So I have a cell with a fixed height with title and content(shown below).

When the screen size gets smaller, the title gets text-overflow:ellipsis;.

Here is the markup that I used for both title and content:

 overflow: hidden; text-overflow: ellipsis; white-space: nowrap; 

However with the content part (simple div), the content extends beyond the container (not shown in the picture). Also because content usually has a paragraph, when i apply the same css markup as above, it goes simply beyond the container in a long line without break.

enter image description here

What I am trying to achieve is the last part (red circle) in the image.

So, I already have outer cell max-heightset. How can I make it so that the content stays within the cell max-height and whatever overflows goes to a next line and text-overflow: ellipsis; is applied instead of a long straight line?

Thanks guys.

3

1 Answer 1

25

Try this:

div { display: -webkit-box; overflow : hidden; text-overflow: ellipsis; -webkit-line-clamp: 3; -webkit-box-orient: vertical; } 
Sign up to request clarification or add additional context in comments.

3 Comments

Got it working by adding overflow:hidden; and what you provided. Thanks!
This works well, and incidentally enough, the display property is crucial.
Could you clarify why this works? For beginners that may not understand display: -webkit-box- and the other webkit rules.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.