I have a div with a fixed width, which has a div with text inside. Parts of the text are in a span for coloring. The text div has all necessary styles for text-overflow with dots at the end (ellipsis), but the dots are not inheriting the span's color, because their definition is on the div. When I put the definition on the span, it ignores its parent's width.
Test code:
.container { width: 120px; } .text { white-space: nowrap; text-overflow: ellipsis; overflow: hidden; } .color { color: #b02b7c; } <div class="container"> <div class="text">Lorem <span class="color">ipsum dolor sit amet, consetetur</span> </div> <!-- works --> <div>Lorem <span class="text color">ipsum dolor sit amet, consetetur</span> </div> <!-- doesn't work --> </div> Is there any clean CSS way to solve this problem? I'd like to stick with text-overflow: ellipsis;, because the other solutions for text truncation are a bit messy in my opinion.
Referrent source at https://www.w3schools.com/cssref/css3_pr_text-overflow.asp