在列表中设置特定项目符号的颜色

时间:2019-05-15 21:15:08

标签: html css list

我有这个CSS:

 .list-mark-3 li:before {
   font-family: 'Font Awesome 5 Free';
    content: '\f101';
    font-weight: 900;
    font-size: 12px;
    color: white !important;
}

和此HTML:

<div class="col-sm-5">
    <ul class="list list-mark-3">
        <li>ABC</li>
        <li class="makeitwhite">DEF</li>
        <li>GHI</li>
    </ul>
</div>

产生如下内容:

enter image description here

但是,我想用DEF白色作为项目符号和相关文字。只是那一颗子弹。我曾尝试在“ makeitwhite”类,内联样式等中将颜色设置为白色。没事!

有什么建议吗?

3 个答案:

答案 0 :(得分:1)

您将为此使用nth-child()

.list-mark-3 li:before {
    font-family: 'Font Awesome 5 Free';
    content: '\f101';
    font-weight: 900;
    font-size: 12px;
    color: white !important;
}

.list-mark-3 li:nth-child(2) {
    color: white;
}

JS Fiddle

要在hover上将其设为白色,请添加以下内容:li:nth-child(2):hover

答案 1 :(得分:1)

也许是这样的:

.list-mark-3 li.makeitwhite
    {
        color:white;
    }

答案 2 :(得分:0)

尝试嵌入式CSS

<div class="col-sm-5">
    <ul class="list list-mark-3">
        <li>ABC</li>
        <li style="color: white;">DEF</li>
        <li>GHI</li>
    </ul>
</div>

相关问题