如何更改元素样式颜色

时间:2017-01-06 23:15:39

标签: html css wordpress

我正在使用wordpress,我正在尝试用css改变h1 / h3标题的颜色,但我不能。

<div class="advisor-title-banner-header">
    <div class="hgroup">
        <a href="http://bashalaprairie.ca">
            <h1 style="color:#ffe2e2;">Basha La Prairie - (450) 444-1777</h1>
            <h3 style="color:#ffe2e2;">La meilleure cuisine libanaise</h3>
        </a>
    </div>
</div>

问题:

element.style {
    color: #ffe2e2;
}

我想将颜色更改为红色。我试过了:

.element.style {
    color: red important!;
}

但它不会起作用。

网站:www.bashalaprairie.ca

我想改变Basha la prairie(450)444-1777的文字颜色 - la meilleur cuisine黎巴嫩菜从白色到红色

感谢!!!

2 个答案:

答案 0 :(得分:2)

您的CSS规则不起作用,因为感叹号位于important关键字的另一端:

示例:

element.style {
    color: red !important;
}

您还必须指定您的元素。对于h2,规则应如下所示:

h2.yourSpecificClass {
    color: red !important;
}

此外,在第二个示例之前,您还有一个额外的点(.)。

答案 1 :(得分:0)

了解CSS Selectors

创建一个CSS来改变你可以写的所有h2的颜色

h2 {
  color: red;
}

如果您想要更具体,可以添加类选择器.classname和其他内容以缩小到单个元素。

它也是!important而不是你写的方式。

相关问题