Html 为什么我的字体颜色设置不起作用?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/4580323/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Why is my font color setting not working?
提问by Tree
I've tried this:
我试过这个:
#ambrosia h3
{
font: 12px/18px Arial,Verdana,sans-serif;
font-color: red;
font-weight: bold;
}
and this:
和这个:
#ambrosia h3
{
font: 12px/18px Arial,Verdana,sans-serif;
color: red;
font-weight: bold;
}
but I still end up with a gray font on my H3 text.
但最终我的 H3 文本仍然是灰色字体。
Why?
为什么?
采纳答案by Nick Craver
You likely have otherCSS that has a more specific selector that's giving your <h3>
that font color, identifying that selector and/or posting your markup would help us provide a more specific selector that wouldoverride the font color.
你可能有其他有多数民众赞成给你一个更具体的选择CSS<h3>
是字体颜色,标识选择器和/或发布您的标记将有助于我们提供了一个更具体的选择将覆盖字体颜色。
回答by JakeParis
Either you have another color set for the id #ambrosia
and that is taking precedence over the generic selector, or you have another tag inside the h3 which has a color assigned to it.
要么您为 id 设置了另一种颜色#ambrosia
,并且优先于通用选择器,要么您在 h3 中有另一个标签,该标签分配了颜色。
Or, in your html you have the #ambrosia applied to the h3
tag, but in your css, you have specified an h3 element which is insidean #ambrosia element. If you are wanting to use <h3 id="ambrosia">
, your css should be
或者,在您的 html 中,您已将 #ambrosia 应用于h3
标签,但在您的 css 中,您指定了一个位于 #ambrosia 元素内的 h3 元素。如果你想使用<h3 id="ambrosia">
,你的 css 应该是
h3#ambrosia { color: red; }
回答by Yoni
You should use Chrome's "Inspect Element" option. Right click on the line and choose Inspect Element and it will show you the path of the CSS evolution of your element.
您应该使用 Chrome 的“检查元素”选项。右键单击该行并选择 Inspect Element,它将显示元素的 CSS 演变路径。
回答by Exoas
the color: red; syntax is correct. however it is possible that you have some other styles in your css file that are conflicting.
颜色:红色;语法正确。但是,您的 css 文件中可能有一些其他样式存在冲突。
you might try using the "firebug" firefox plugin. it will allow you to select the element and see exactly which style is applied to the element and if your class is being overridden
您可以尝试使用“firebug”firefox 插件。它将允许您选择元素并查看应用到元素的确切样式以及您的类是否被覆盖