简体   繁体   English

如何更改这两行HTML,以便可以将其放入CSS?

[英]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.

相关问题 我的css和html结构非常奇怪,我怎样才能使我的聊天窗口随浏览器调整大小? - My css and html are structured very weirdly, how can I make it so that my chat window resizes with the browser? HTML / CSS-如何更改间距或添加空格,以使方框相等? - HTML/CSS - How can I change the spacing or add whitespace so the boxes are equal? 我如何在HTML中使用CSS - How can i use my css in html 如何使用 css 将 animation 放到带边框的 html 元素上,但也没有边框动画? - How can I put animation onto my bordered html element with css but NOT have it's border animate as well? 如何将我的网站徽标放在 html 和 css 的左上角? - How can i put the logo of my website on the upper-left corner in html and css? 如何将我的所有资产(Html、JS、CSS、node.JS)放入反应中? - How can I put my all asset(Html, JS, CSS, node.JS) into the react? 如何在 html&amp;css 中的下拉菜单之间放置空格 - How can i put space between my dropdown menu in html&css 如何使用CSS HTML在此形状中绘制这样的2行 - How can I draw such 2 lines in this shape using CSS HTML 如何使用 HTML/CSS 在表单旁边放置图像? - How can I put images next to the form using HTML/CSS? 如何在 html 和 css 上的图像链接轮廓上添加颜色? - How can I put color on a Image link outline on html and css?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM