首页
学习
活动
专区
工具
TVP
发布
精选内容/技术社群/优惠产品,尽在小程序
立即前往

颜色索引 | @media.color-index

@media.color-index

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

语法

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

实例

基本实例

HTML

代码语言:javascript
复制
<p>This is a test.</p>

CSS

代码语言:javascript
复制
p {
? color: black;
}

@media (color-index) {
? p {
?   color: red;
? }
}

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

结果

自定义样式表

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

代码语言:javascript
复制
<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" />

规范

Specification

Status

Comment

Media Queries Level 4The definition of 'color-index' in that specification.

Working Draft

The value can now be negative, in which case it computes to false.

Media QueriesThe definition of 'color-index' in that specification.

Recommendation

Initial definition. The value must be nonnegative.

浏览器兼容性

Feature

Chrome

Firefox (Gecko)

Internet Explorer

Opera

Safari

Basic support

(Yes)

?

?

?

?

Feature

Android

Firefox Mobile (Gecko)

IE Mobile

Opera Mobile

Safari Mobile

Basic support

?

?

?

?

?

扫码关注腾讯云开发者

领取腾讯云代金券

http://www.vxiaotou.com