0

I can't seem to get the ellipsis to display. The text just wraps to the next line.

text {
   display: inline;
   overflow: hidden;
   text-align: center;
   text-overflow: ellipsis;
}

grid {
   width: 200px;
   height: 3em;
   border: 1px solid #000000ff;
   display: grid;
   grid-template-columns: 1fr;
}
<grid><text>This text should display an ellipsis instead of wrapping!</text></grid>
spacefluff432
  • 566
  • 3
  • 13

2 Answers2

1

add white-space: nowrap;to text

text {
   display: inline;
   overflow: hidden;
   text-align: center;
   text-overflow: ellipsis;
   white-space: nowrap;
}

grid {
   width: 200px;
   height: 3em;
   border: 1px solid #000000ff;
   display: grid;
   grid-template-columns: 1fr;
}
<grid><text>This text should display an ellipsis instead of wrapping!</text></grid>
Ram Segev
  • 2,563
  • 2
  • 12
  • 24
1

Please apply css for nowrap to the text, as following:

text {
       display: inline;
       overflow: hidden;
       text-align: center;
       white-space: nowrap;
       text-overflow: ellipsis;
    }
    
    grid {
       width: 200px;
       height: 3em;
       border: 1px solid #000000ff;
       display: grid;
       grid-template-columns: 1fr;
    }
<grid><text>This text should display an ellipsis instead of wrapping!</text></grid>
Khurram Ishaque
  • 778
  • 1
  • 9
  • 26