With CSS is there any way to change the style of Text-Overflow: Ellipsis?

6

Imagine that I have a situation where the text is larger than the container , so I'll use text-overflow: ellipsis to put the 3 dots ... showing that the text goes on and on inside container has more content, so far so good.

The problem is that I want to customize my ... with another color and wanted to bold . Hand did not find a way to do this. I would like something like the image below

Isthereanywaytocustomizetext-overflow:ellipsisinastyledifferentfromtheonealreadyappliedtothecontainerwiththetext?

WhatIhavesofaristhis:

div.b {
    white-space: nowrap; 
    width: 70px; 
    overflow: hidden;
    text-overflow: ellipsis; 
    border: 1px solid #000000;
}
<div class="b">Hello world!</div>
    
asked by anonymous 13.11.2018 / 11:19

1 answer

0

I think this is what you want. removed overflow English

  • You have to rewrite the default text-styling
  • you will need <span> (or any other) element
  • .text-overflow
    {
      color: blue;
      font-weight: bold;
      font-size: 20px;
    
      overflow: hidden;
      text-overflow: ellipsis;
      width: 100px;
      white-space: nowrap;
    }
    
    .text-overflow > span
    {
      font-weight: normal;
      color: black;
      font-size: 14px;
    }
    <div class="text-overflow">
    <span>Here is some very nice text indeed. So this is getting long</span>
    </div>
        
    13.11.2018 / 11:26