这是
实验性技术
检查
浏览器兼容性表格
要小心谨慎在生产中使用这之前。
prefers-contrast
CSS
media feature
is used to detect if the user has requested that the web content is presented with a higher (or lower) contrast.
no-preference
Indicates that the user has made no preference known to the system. This keyword value evaluates as false in a Boolean context.
more
Indicates that user has notified the system that they prefer an interface that has a higher level of contrast.
less
Indicates that user has notified the system that they prefer an interface that has a lower level of contrast.
Various operating systems do support such preferences and user agents are likely to rely on the settings provided by the operating system.
This example has an annoying low contrast by default.
<div class="contrast">low contrast box</div>
.contrast {
width: 100px;
height: 100px;
outline: 2px dashed black;
}
@media (prefers-contrast: high) {
.contrast {
outline: 2px solid black;
}
}
| 规范 | 状态 | 注释 |
|---|---|---|
|
Media Queries Level 5
The definition of 'prefers-contrast' in that specification. |
编者草案 | 初始定义。 |
| Desktop | Mobile | |||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|
prefers-contrast
media feature
Experimental
|
Chrome 不支持 No | Edge 不支持 No |
Firefox
完整支持
80
Disabled
|
IE 不支持 No | Opera 不支持 No | Safari 不支持 No | WebView Android 不支持 No | Chrome Android 不支持 No | Firefox Android 不支持 No | Opera Android 不支持 No | Safari iOS 不支持 No | Samsung Internet Android 不支持 No |
完整支持
不支持
实验。期望将来行为有所改变。
用户必须明确启用此特征。