为什么是“rgb(224,226,213)”,一个无效的属性值? [英] Why is "rgb (224, 226, 213)" an invalid property value?

查看:85
本文介绍了为什么是“rgb(224,226,213)”,一个无效的属性值?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

为什么任何浏览器都不能应用此颜色rgb规则?

Why can't any browser apply this color rgb rule?

HTML

<header>
    <h1>Header</h1>
</header>

CSS

header h1 {
    background-color: red;
    color: rgb (224, 226, 213);
}

Chrome Web开发人员工具告诉我这是一个无效的属性值,不明白为什么。您可以在 JSFiddle 中查看结果。

Chrome Web Developer tools is telling me that it's an invalid property value, but I can't understand why. You can see the result in JSFiddle.

推荐答案

rgb ,这是不允许的:

header h1 {
    background-color: red;
    color: rgb(224, 226, 213);
}

不,我很认真,不是。

与许多编程语言不同,CSS明确禁止在函数名和开始括号之间留空格。只有 rgb() rgba(),还有其他功能值如 url() attr(),以及功能伪类,如:nth-​​child / code>,:lang():not()

Unlike many programming languages, CSS expressly forbids having whitespace between a function name and the opening parenthesis. This applies not only to rgb() and rgba(), but also to other functional values such as url() and attr(), as well as functional pseudo-classes such as :nth-child(), :lang() and :not().

请参阅 CSS2的第4.3.6节.1 ,其中规定:


函数符号中的RGB值的格式为'rgb逗号分隔的三个数值列表(三个整数值或三个百分比值),后跟')'。

The format of an RGB value in the functional notation is 'rgb(' followed by a comma-separated list of three numerical values (either three integer values or three percentage values) followed by ')'. [...] White space characters are allowed around the numerical values.

还可以参考

{ident}"("      {return FUNCTION;}

这篇关于为什么是“rgb(224,226,213)”,一个无效的属性值?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆