How to summarize a text within the <span>?

Asked

Viewed 329 times

6

Well I have the following code:

<span>TÍTULO CONTAINER TEXO TEXTO TEXO TEXTO</span>

I need this span has been width: 100% and that has no line break, if the text is too large it has to summarize and put (...).

You can do this with css?

1 answer

6


You can define the text-overflow as Ellipsis in his style:

span {
     text-overflow: ellipsis;
 }

Example:

span {
  display: inline-block;
  width: 100%;
  white-space: nowrap;
  overflow: hidden !important;
  text-overflow: ellipsis;
}
<span>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Fusce maximus dui eu libero facilisis venenatis. Pellentesque placerat vulputate semper. </span>

  • 1

    A tip, always search before and preferably mark the answer as dup, even if you answer it http://answall.com/search?tab=votes&q=ellipsis%20%5bcss%5d

  • has how to do this without 'width: 100%;'?

  • 1

    Agree @Guilhermenascimento, also scored :P

  • In the example I gave width is 100% @Hugoborges, that’s not it?

  • yes that’s right.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.