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.
<p>This is a test.</p>
p {
color: black;
}
@media (color-index) {
p {
color: red;
}
}
@media (min-color-index: 15000) {
p {
color: #1475ef;
}
}
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. |
| Desktop | Mobile | |||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|
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 |
完整支持
不支持