Set dot color of `text-overflow: ellipsis`

后端 未结 1 944
被撕碎了的回忆
被撕碎了的回忆 2020-12-16 09:22

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

相关标签:
1条回答
  • 2020-12-16 09:56

    If I understand your issue correctly, this might work for you:

    .container {
        width:120px;
        background: lightgray;
    }
    .text {
        white-space: nowrap;
        text-overflow: ellipsis;
        overflow: hidden;
        color:#b02b7c;
    }
    .color {
        color: black;
    }
    <div class="container">
        <div class="text"><span class="color">Lorem</span> ipsum dolor sit amet, consetetur
        </div><!-- works -->
    </div>

    Demo Fiddle

    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.

    0 讨论(0)
提交回复
热议问题