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

颜色查找 | @media.color

color CSS @media媒体功能可用于根据每个输出设备的RGB色彩分量(红色,绿色,蓝色)的比特的数量来应用样式。

语法

color功能被指定为<integer>,值表示输出设备每个颜色分量(红,绿,蓝)的位数的值。如果设备不是彩色设备,则值为零。这是一个范围功能,也就是说,您也可以使用前缀min-colormax-color变量分别查询最小值和最大值。

注:如果用不同的位数表示不同的颜色分量,则使用最小的数目。例如,如果显示器使用5位用于蓝色和红色,6位用于绿色,那么该设备被认为每种颜色组件使用5位。如果设备使用索引颜色,则使用颜色表中每个颜色分量的最小位数。

请参阅使用CSS将颜色应用于HTML元素 以了解有关使用CSS将颜色应用于HTML更多信息。

HTML

代码语言:javascript
复制
<p>How many bits does your device support for color components?</p>

CSS

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

/* Any color device */
@media (color) {
? p {
  ? color: #ff0000;
? }
}

/* Any color device with at least 8 bits per color component */
@media (min-color: 8) {
? p {
?   color: #35bd19;
? }
}

结果

规范

Specification

Status

Comment

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

Working Draft

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

Media QueriesThe definition of 'color' in that specification.

Recommendation

Initial definition. The value must be nonnegative.

浏览器兼容性

Feature

Chrome

Firefox (Gecko)

Internet Explorer

Opera

Safari

Basic support

(Yes)

(Yes)

?

(Yes)

(Yes)

Feature

Android

Firefox Mobile (Gecko)

IE Mobile

Opera Mobile

Safari Mobile

Basic support

?

?

?

?

?

扫码关注腾讯云开发者

领取腾讯云代金券

http://www.vxiaotou.com