如何更改元素样式颜色

时间:2022-11-20 21:24:34

I am using wordpress and i am trying to change the color of a h1/h3 heading by css but i cant.

我正在使用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>

Problem:

问题:

element.style {
    color: #ffe2e2;
}

i want to change the color to red. I tried:

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

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

but it wouldnt work.

但它不会起作用。

website: www.bashalaprairie.ca

网站:www.bashalaprairie.ca

I want to change the text color of Basha la prairie (450) 444-1777 - la meilleur cuisine lebanese from white to red

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

thanks!!!

谢谢!!!

2 个解决方案

#1


2  

Your CSS rule isn't working because the exclamation mark goes on the other way of the important keyword:

您的CSS规则无效,因为感叹号与重要关键字相反:

Example:

例:

element.style {
    color: red !important;
}

You also have to specify your element. For a h2, the rule should look like this:

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

h2.yourSpecificClass {
    color: red !important;
}

In addition, you have an extra dot (.) before your second example.

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

#2


0  

Read about CSS Selectors

阅读CSS选择器

To create a CSS to change the color of ALL h2 you could write

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

h2 {
  color: red;
}

If you want to be more specific you can add class selectors .classname and other things to narrow down to the single element.

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

Also it is !important instead of the way you wrote.

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

#1


2  

Your CSS rule isn't working because the exclamation mark goes on the other way of the important keyword:

您的CSS规则无效,因为感叹号与重要关键字相反:

Example:

例:

element.style {
    color: red !important;
}

You also have to specify your element. For a h2, the rule should look like this:

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

h2.yourSpecificClass {
    color: red !important;
}

In addition, you have an extra dot (.) before your second example.

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

#2


0  

Read about CSS Selectors

阅读CSS选择器

To create a CSS to change the color of ALL h2 you could write

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

h2 {
  color: red;
}

If you want to be more specific you can add class selectors .classname and other things to narrow down to the single element.

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

Also it is !important instead of the way you wrote.

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