[英]How can I change this 2 lines of HTML so that i can put it into my CSS?
How can i target the red text in CSS? 如何在CSS中定位红色文本? I need to change the color of all the red text to orange:
我需要将所有红色文本的颜色更改为橙色:
<span style="color: #dc143c;"><strong>Red text that must be Orange</strong></span>
I tried with the following, but i don't really know how should I write it to make it work.. 我尝试了以下方法,但是我真的不知道如何编写才能使其工作..
span[style="color: #dc143c;"] {
color:#f7941d !important;
}
Thanks for your help! 谢谢你的帮助!
Place the all red code in <span>
tag then in css target the <span>
and give them class tag to change it color to red code given below 将所有红色代码放在
<span>
标记中,然后在CSS中将<span>
定位到目标,并给它们class标签以将其颜色更改为下面给出的红色代码
<span class="red-text">this is red text</span>
css code: CSS代码:
.red-text {color:#f7941d;}
You should remove the style tag from your html completely and use classes instead. 您应该从html中完全删除样式标签,而应使用类。
<span class="colored"><strong>colored text</strong></span>
then select the class in your css instead 然后在您的CSS中选择类
.colored {
color: orange;
}
Give your Red Text an ID or Class of color-change etc. 给您的红色文字一个ID或颜色变化的类别等。
<span class="color-change" style="color: #dc143c;"><strong>Red text that must be Orange</strong></span>
now in your css 现在在你的CSS
.color-change {
color:#f7941d !important;
}
One More Thing not use inline css because inline css has maximum priority if you use inline css must use !important keyword to change color. 还有一点不使用内联css,因为如果使用内联css,内联css具有最高优先级,则必须使用!important关键字来更改颜色。
<span id="change">this is red text</span>
css code: CSS代码:
#change {
color:#f7941d;
}
Try this Hope this help you 试试这个,希望对您有帮助
Add the class orange at the strong tag: 在强标签处添加橙色类:
<span style="color: #dc143c;"><strong class="orange">Red text that must be Orange</strong></span>
In the .css file: 在.css文件中:
.orange {
color: #f7941d !important; 颜色:#f7941d!重要; }
}
I think it would be easier to use a class or id for the span and target it whenever you want using javascript or jquery. 我认为使用class或id作为跨度并在需要使用javascript或jquery时将其定位会更容易。 example
例
Red text must be orange 红色文字必须为橙色
with jquery you can do this: $('.OrangeRedSpan').css('color': #FE9A2E); 使用jquery,您可以执行以下操作:$('。OrangeRedSpan')。css('color':#FE9A2E);
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.