CSS 数据类型 一个 语法
备注: 尽管 CSS 颜色值被精确定义,但在不同的输出设备上仍然有可能显示不一。它们大多数是不可被校准的,而且有些浏览器不支持输出设备的色彩配置(color profile)。 颜色关键字颜色关键字(color keywords)是不区分大小写的标识符,它表示一个具体的颜色,例如 在使用关键字时有几个需要留意的注意事项:
备注: 可接受的关键字列表在 CSS 的演变过程中发生了改变:
transparent 关键字
备注: 为避免未预料的行为,比如 备注: currentColor 关键字
它也能用于那些继承了元素的 currentcolor 示例该行的颜色(一个填充颜色的 div)应用它继承自父级的 HTML
结果RGB 颜色颜色可以使用红 - 绿 - 蓝(red-green-blue (RGB))模式的两种方式被定义: 语法RGB
颜色可以通过以 备注: 在 CSS 颜色标准 4 中,rgba() 是 rgb() 的别称。在实行第 4 级标准的浏览器中,它们接受相同的参数,作用效果也相同。 十六进制符号:#RRGGBB[AA]
#RGB[A]
rgb[a](R, G, B[, A])
rgb[a](R G B[ / A]) CSS 颜色级别 4 支持用空格分开的值。 HSL 颜色颜色也可以使用 Many designers find HSL more intuitive than RGB, since it allows hue, saturation, and lightness to each be adjusted independently. HSL can also make it easier to create a set of matching colors (such as when you want multiple shades of a single hue). 语法HSL colors are expressed through the functional 备注: As of CSS Colors Level 4, hsl[a](H, S, L[, A]) hsl[a](H S L[ / A]) CSS Colors Level 4 adds support for space-separated values in the functional notation. 系统颜色In forced colors mode (detectable with the forced-colors (en-US) media query), most colors are restricted into a user- and browser-defined palette. These system colors are exposed by the following keywords, which can be used to ensure that the rest of the page integrates well with the restricted palette. These values may also be used in other contexts, but are not widely supported by browsers. The keywords in the following list are defined by the CSS Color Module Level 4 specification. 备注: Note that these keywords are case insensitive, but are listed here with mixed case for readability. ActiveTextText of active links ButtonFaceBackground of push buttons ButtonTextText of push buttons CanvasBackground of application content or documents CanvasTextText in application content or documents FieldBackground of input fields FieldTextText in input fields GrayTextText that is disabled HighlightBackground of items that are selected in a control HighlightTextText of items that are selected in a control LinkTextText of non-active, non-visited links VisitedTextText of visited links Deprecated system color keywordsThe following keywords were defined in earlier versions of the CSS Color Module. They are now deprecated. 已弃用 for use on public web pages. ActiveBorderActive window border. ActiveCaptionActive window caption. Should be used with Background color of multiple document interface. Desktop background. ButtonHighlightThe color of the border facing the light source for 3-D elements that appear 3-D due to that layer of surrounding border. ButtonShadowThe color of the border away from the light source for 3-D elements that appear 3-D due to that layer of surrounding border. CaptionTextText in caption, size box, and scrollbar arrow box. Should be used with the Inactive window border. InactiveCaptionInactive
window caption. Should be used with the Color of text in an inactive caption. Should be used with the Background color for tooltip controls. Should be used with the Text color for tooltip controls. Should be used with the Menu background. Should be used with the Text in menus. Should be used with the Background color of scroll bars. ThreeDDarkShadowThe color of the darker (generally outer) of the two borders away from the light source for 3-D elements that appear 3-D due to two concentric layers of surrounding border. ThreeDFaceThe face background color for 3-D elements that appear 3-D due to two concentric layers of surrounding border. Should be used with the The color of the lighter (generally outer) of the two borders facing the light source for 3-D elements that appear 3-D due to two concentric layers of surrounding border. ThreeDLightShadowThe color of the darker (generally inner) of the two borders facing the light source for 3-D elements that appear 3-D due to two concentric layers of surrounding border. ThreeDShadowThe color of the lighter (generally inner) of the two borders away from the light source for 3-D elements that appear 3-D due to two concentric layers of surrounding border. WindowWindow background. Should be used with the Window frame. WindowTextText in windows. Should be used with the Mozilla System Color Extensions-moz-ButtonDefault The border color that goes around buttons that represent the default action for a dialog box. -moz-ButtonHoverFaceThe background color of a button that the mouse pointer is over (which would be The text color
of a button that the mouse pointer is over (which would be ButtonText when the mouse pointer is not over it). Should be used with the Background color for selected item in a tree widget. Should be used with the Text color for a selected item in a tree. Should be used with the Background color for combo-boxes. Should be used with the Text color for combo-boxes. Should be used with the Background color for dialog boxes. Should be used
with the Text color for dialog boxes. Should be used with the TBD -moz-EvenTreeRowBackground color for even-numbered rows in a tree. Should be used with the Background color for highlighted item in HTML Text color for highlighted items in HTML
TBD -moz-mac-accentdarkshadowTBD -moz-mac-accentfaceTBD -moz-mac-accentlightesthighlightTBD -moz-mac-accentlightshadowTBD -moz-mac-accentregularhighlightTBD -moz-mac-accentregularshadowTBD -moz-mac-chrome-activeTBD -moz-mac-chrome-inactiveTBD -moz-mac-focusringTBD TBD -moz-mac-menushadowTBD TBD Background color for hovered menu items. Often similar to Text color for hovered menu items. Often similar to Text color in menu bars. Often similar to Color for hovered text in menu bars. Often similar to Default platform hyperlink color. -moz-OddTreeRowBackground color for odd-numbered rows in a tree. Should be used with the Should be used for text in objects with Should be used for text in objects with Used to access the Windows 10 custom accent color that you can set on the start menu, taskbar, title bars, etc. -moz-win-accentcolortextUsed to access the color of text placed over the Windows 10 custom accent color in the start menu, taskbar, title bars, etc. Mozilla Color Preference Extensions-moz-activehyperlinktext User's preference for text color of active links. Should be used with the default document background color. -moz-default-background-colorUser's preference for the document background color. -moz-default-colorUser's preference for the text color. -moz-hyperlinktextUser's preference for the text color of unvisited links. Should be used with the default document background color. -moz-visitedhyperlinktextUser's preference for the text color of visited links. Should be used with the default document background color. 插值在动画和渐变中, Accessibility considerationsSome people have difficulty distinguishing colors. The WCAG 2.0 recommendation strongly advises against using color as the only means of conveying a specific message, action, or result. See Color and color contrast for more information. 示例颜色值检测器在这个示例中,我们提供一个 HTML
CSS
结果RGB 的多种语法这个例子显示了一个颜色可以以多种 RGB 颜色语法表示。
RGB 的多种透明度
HSL 的多种语法
完全饱和颜色
不同明暗度的绿色
饱和的和不饱和的绿色
HSL 不同的透明度
Specifications
浏览器兼容性BCD tables only load in the browser 参见
|