如何更改 html 中的字体颜色

问题描述

我的代码的相关部分是:

<p style="font-family:'impact',color:red">
            something          
</p>

问题是我不能同时使用颜色和字体。 如果我单独使用 font-family 属性,它可以完美运行。 如果我单独使用 color 属性,它可以完美运行。 但是如果我同时使用这两个属性,如上所示,它们都不起作用。

我在我的内联样式代码中犯了什么错误?使用 style 属性更改多个 CSS 属性的正确方法是什么?

解决方法

这样写:

<p style="font-family:'impact'; color:red"></p>
,

当使用 style 属性将独特的样式应用到单个段落元素时,您应该在每个 CSS 属性后包含一个分号。

<p style="color: red;">
This text is red
</p>

<p style="font-family: impact;">
This text is impact font
</p>

<p style="color: red; font-family: impact;">
This text is red and impact font
</p>

相关问答

错误1:Request method ‘DELETE‘ not supported 错误还原:...
错误1:启动docker镜像时报错:Error response from daemon:...
错误1:private field ‘xxx‘ is never assigned 按Alt...
报错如下,通过源不能下载,最后警告pip需升级版本 Requirem...