Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

The ellipsis '...' value is not the right color

Tags:

html

css

I have a table with 3 dots '...' at the end of each line when necessary (text overflow). I used the ellipsis value of the text-overflow property. It works: when the window is resized, the '...' are showed but I have 2 problems when the line in my table contains a span:

  • the '...' are colored in the font color of the span
  • the '...' are resized the size of the font of the span

See demo here: http://jsfiddle.net/Ah4DR/1/

Maybe this is a novice question but I searched for a time and not found any solution.

I forgot to say that this don't works on Internet Explorer but works fine on Chrome.

Thanks!

like image 793
Bronzato Avatar asked Nov 12 '11 07:11

Bronzato


People also ask

How do I change the color of my ellipsis?

If the ellipsis is taking the color of the div, then make the div the color you want the ellipsis to be, and use . color to set the initial text black.

Why is ellipsis not working CSS?

So, if you've arrived at this question because you're having difficulties getting the ellipsis to operate inside a display: Try adding min-width: 0 to the outmost container that's overflowing its parent, even if you've previously set overflow: hidden to it, and see how it works for you.

What is ellipsis in CSS?

ellipsis. This keyword value will display an ellipsis ( '…' , U+2026 HORIZONTAL ELLIPSIS ) to represent clipped text. The ellipsis is displayed inside the content area, decreasing the amount of text displayed. If there is not enough space to display the ellipsis, it is clipped.

How do I fix text-overflow in CSS?

A text-overflow property in CSS is used to specify that some text has overflown and hidden from view. The white-space property must be set to nowrap and the overflow property must be set to hidden. The overflowing content can be clipped, display an ellipsis ('…'), or display a custom string.


2 Answers

I had the same problem; while my text was white on dark-grey, the ellipsis color seemed to be black. I solved it by simply setting the color of the that contained the text-overflow: ellipsis, like this:

.ellipsis-div {
    white-space: nowrap;
    width: 154px;
    overflow: hidden;
    text-overflow: ellipsis;
    color: white;       /* --> ellipsis color */
}
like image 118
Roger Hoen Avatar answered Oct 27 '22 20:10

Roger Hoen


It certainly seems to be a bug in IE. It is (for whatever reason) reading the color of first element (or maybe it is the first content) to determine the color of the ellipsis. However, I did find a "work around" for the bug. I would recommend if possible setting this up in some way to just target IE (and only the td elements you are using text-overflow on), but as a proof of concept, this fixes it:

td:before {content: ''; color: black;}

Apparently the first td content that is defining the color need not be real content, because the pseudo content worked.

like image 24
ScottS Avatar answered Oct 27 '22 22:10

ScottS