0

Is there any way to display text in two line and overflow is dotted? I can use

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

But it show the text in one line. I need to show my text in two line and if overflow text then it should show dotted end.

Md. Shougat Hossain
  • 501
  • 2
  • 8
  • 24

3 Answers3

2

Working CSS solution for Chrome, Safari and Opera is:

display: -webkit-box;
-webkit-line-clamp: 2;
-webkit-box-orient: vertical;
overflow: hidden;
text-overflow: ellipsis;

You can change 2 to any number. It will show X number of text and dots at the end

line-clamp is not supported by all browsers. https://caniuse.com/#search=line-clamp

Victor Leontyev
  • 8,488
  • 2
  • 16
  • 36
0

At css set width of element, white-space to pre

div  {
  font-size: 1em;
  display: inline-block;
  width: 2em;
  white-space: pre;
  text-overflow: ellipsis;
  overflow: hidden;
}
<div>lines of 
breaks</div>
guest271314
  • 1
  • 15
  • 104
  • 177
0

Remove White-space Property and use a height of the element

S.M. Shakil
  • 159
  • 6