color-index CSS media feature can be used to test the number of entries in the output device's color lookup table.

句法

color-index feature is specified as an <integer> value representing the number of entries in the output device's color lookup table. (This value is zero if the device does not use such a table.) It is a range feature, meaning that you can also use the prefixed min-color-index and max-color-index variants to query minimum and maximum values, respectively.

范例

基本范例

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;
  }
}
					

结果

Custom stylesheet

This HTML will apply a special stylesheet for devices that have at least 256 colors.

<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" />
					

规范

规范 状态 注释
Media Queries Level 4
The definition of 'color-index' in that specification.
候选推荐 The value can now be negative, in which case it computes to false.
Media Queries
The definition of 'color-index' in that specification.
推荐 Initial definition. The value must be nonnegative.

浏览器兼容性

The compatibility table on this page is generated from structured data. If you'd like to contribute to the data, please check out https://github.com/mdn/browser-compat-data and send us a pull request. 更新 GitHub 上的兼容性数据
Desktop Mobile
Chrome Edge Firefox Internet Explorer Opera Safari Android webview Chrome for Android Firefox for Android Opera for Android Safari on iOS Samsung Internet
color-index media feature Chrome 完整支持 29 Edge 完整支持 79 Firefox 不支持 No IE 不支持 No Opera 完整支持 16 Safari 完整支持 8 WebView Android 完整支持 ≤37 Chrome Android 完整支持 29 Firefox Android 不支持 No Opera Android 完整支持 16 Safari iOS 完整支持 8 Samsung Internet Android 完整支持 2.0

图例

完整支持

完整支持

不支持

不支持

元数据

  • 最后修改: