首页 > 解决方案 > 使用html和css在同一文本中使用两种不同的颜色

问题描述

我想为我的文本设置两种不同的颜色。我的文字是短语 1 / 短语 2,我想将黑色设置为短语 1 / 将绿色设置为短语 2

<label class="diffcolor">pharse1/ phrase2</label>

我的例子

<label class="diffcolor">pharse1/ </label>

CSS:

.different::after{
    color : green;
    content :"phrase2";
}

我的 Internet Explorer 浏览器无法正常工作。我怎样才能做到这一点 ?

标签: htmlcsscss-selectors

解决方案


label.class { color:#4C4C4C }
span.name { color:#FF0000; }
<label class="diffcolor">pharse1/ <span class="name">phrase2</span></label>


推荐阅读