CSS

颜色索引 | @media.color-index

color-index CSS @media媒体功能可用于基于条目的输出设备的颜色查找表的数量应用样式。

语法

该color-index功能被指定为<integer>值表示输出设备的颜色查找表中的条目数量的值。(如果设备不使用这样的表,则此值为零)。这是一个范围特性,也就是说,也可以使用前缀min-color-index和max-color-index变量分别查询最小值和最大值。

实例

基本实例

HTML

<p>This is a test.</p>

CSS

p {   color: black; } @media (color-index) {   p {   color: red;   } } @media (min-color-index: 15000) {   p {   color: #1475ef;   } }

结果

自定义样式表

此HTML将为至少有256种颜色的设备应用特殊的样式表。

<link rel="stylesheet" href="http://foo.bar.com/base.css" /> <link rel="stylesheet" media="all and (min-color-index: 256)" href="http://foo.bar.com/color-stylesheet.css" />

规范

SpecificationStatusComment
Media Queries Level 4The definition of 'color-index' in that specification.Working DraftThe value can now be negative, in which case it computes to false.
Media QueriesThe definition of 'color-index' in that specification.RecommendationInitial definition. The value must be nonnegative.

浏览器兼容性

FeatureChromeFirefox (Gecko)Internet ExplorerOperaSafari
Basic support(Yes)????

FeatureAndroidFirefox Mobile (Gecko)IE MobileOpera MobileSafari Mobile
Basic support?????