0

I am div holding text, I don't want the div to be higher than a certain size or wider than a certain size. I've set the max width and max height on that already. My problem right now is that when the text is so long it gives problems. Is there a way I am able to cut the text off when it has to do a line break?

Edit: I would like two lines of text before the ellipsis start.

JoeTheHobo
  • 137
  • 10

2 Answers2

0

It looks like you can either have the text appearing on a single line with the ellipsis or have two lines without ellipsis.

Try this for a single line with an ellipsis:

.overflow {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

OR this for two lines without an ellipsis:

.overflow {
    text-overflow: ellipsis;
    line-height: 1.5em;
    height: 3em;
    overflow: hidden;
}

Here's a Sample Fiddle for your ref.

SiddAjmera
  • 38,129
  • 5
  • 72
  • 110
0

Try this:

.overflow {
  line-height: 1.5em;
  height: 3em;
  overflow: hidden; 
  text-overflow: ellipsis;
}

This will keep your text max up to 2 lines.

SiddAjmera
  • 38,129
  • 5
  • 72
  • 110
krishna_tandon
  • 395
  • 1
  • 12