英文:
Font Color does not update
问题
我有一个简单的HTML片段,如下所示:
<!-- begin snippet: js hide: false console: true babel: false -->
<!-- language: lang-html -->
<p align="left"> <font size="3"><strong> Asset: </strong></font><strong><font color="blue" size="2"> something something here </font></strong><br> </p>
<!-- end snippet -->
字体颜色似乎不起作用,但字体大小确实有变化。
此外,我了解到显式的font
描述已过时,我们应该使用CSS样式。如果您可以提出这个选项,是否可以使用这个选项?
英文:
I have a simple HTML snippet like this:
<!-- begin snippet: js hide: false console: true babel: false -->
<!-- language: lang-html -->
<p align= "left"> <FONT size=3><STRONG> Asset: &nbsp; </STRONG></FONT><STRONG><FONT color="blue" size=2> something something here </FONT></STRONG><br> </p>
<!-- end snippet -->
The font color does not seem to work but the font size does change.
Also, I do understand that explicit font
description is expiring and we should be using the CSS styling. If you could suggest that option,okay to use that option as well.
答案1
得分: 2
最好使用 CSS:
<p style="text-align:center; font-size:14px;"><strong> 资产:&nbsp;</strong><strong style="color:blue;">这里是一些内容</strong><br></p>
英文:
Is better to use css:
<p style="text-align:center; font-size:14px;"><strong> Asset: &nbsp;</strong><strong style="color:blue;">something something here</strong><br></p>
答案2
得分: 1
使用HTML元素和类是更好的选择,尽管我承认有些可能看起来过于复杂。
对于我的回答,首先我给段落添加了一个类。在其中,我将文本对齐到左侧并将其中的所有内容设置为加粗。
接下来,span元素默认是内联的(意味着它们与文本一起内联显示,但不能控制间距)。您也可以使用div。因此,段落标签中的每个span,我都将其设置为内联块,以便我可以控制其周围的间距,同时保持文本内联。
接下来,每个内容部分都被包装在自己的span中。
由于之前我已经将所有内容设置为加粗,所以我只会给标题span添加右边的边距以进行间距处理,并更改字体大小。
接下来,对于其余部分,我将其内容包装在另一个span中,并将颜色更改为蓝色(十六进制为#红色 绿色 蓝色),同时也更改了字体大小。
<!-- begin snippet: js hide: false console: true babel: false -->
<!-- language: lang-css -->
.updated{
text-align:left;
font-weight:bold;
}
.updated span{
display:inline-block;
}
.updated .title{
margin-right:5px;
font-size:18px;
}
.updated .content{
color:#0000FF;
font-size:13px;
}
<!-- language: lang-html -->
Originial: <p align="left"> <FONT size=3><STRONG> Asset: </STRONG></FONT><STRONG><FONT color="blue" size=2> something something here </FONT></STRONG><br> </p>
Updated:
<p class="updated">
<span class="title">Asset:</span>
<span class="content">something something here</span>
</p>
<!-- end snippet -->
英文:
Using HTML elements and classes is the better option although I do admit some might seem overly complicated.
For my answer, first I give the paragraph a class. Inside of it, I'm aligning the text left and bolding EVERYTHING in it.
Next, spans are by default inline (meaning they show inline with the text, but you don't have control over the spacing). You could also use a div. So every span in the paragraph tag, I'm setting to inline block so I can control the spacing around it while keeping the text inline.
Next each part of the content gets wrapped in its own span.
Since earlier I already set all content to bold, I'm only going to give the title span a margin to the right to space it out and change the font size.
Next for the rest I wrapped that content in another span and changed the color to blue (hex is #Red Green Blue) and I changed the font size also.
<!-- begin snippet: js hide: false console: true babel: false -->
<!-- language: lang-css -->
.updated{
text-align:left;
font-weight:bold;
}
.updated span{
display:inline-block;
}
.updated .title{
margin-right:5px;
font-size:18px;
}
.updated .content{
color:#0000FF;
font-size:13px;
}
<!-- language: lang-html -->
Originial: <p align= "left"> <FONT size=3><STRONG> Asset: &nbsp; </STRONG></FONT><STRONG><FONT color="blue" size=2> something something here </FONT></STRONG><br> </p>
Updated:
<p class="updated">
<span class="title">Asset:</span>
<span class="content">something something here</span>
</p>
<!-- end snippet -->
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论