【发布时间】:2021-01-04 16:45:21
【问题描述】:
我正在寻找一种简单的方法来检测用户的系统是否处于高对比度模式或未在 react 应用程序中使用 javascript/typescript。
在某个地方的库中是否有可用的公共方法?
这些 stackoverflow 帖子没有给我我正在寻找的东西,这是一种来自导入的方法:
Detect if 'High contrast' is enabled in Android accessibility settings
How to detect MAC OS inverted color mode in JavaScript / CSS?
How do I detect if a user has Mac OS high contrast accessibility settings enabled?
编辑:我打算能够区分黑底白字和黑底白字
编辑:这是我尝试过的,但没有在 Chrome 中应用
/* Targets displays using the Windows’ "High Contrast Black" theme: */
@media screen and (-ms-high-contrast: white-on-black) {
.targetClass {
color: white;
background-color: black;
}
}
/* Targets displays using the Windows’ "High Contrast White" theme: */
@media screen and (-ms-high-contrast: black-on-white) {
.targetClass {
color: black;
background-color: white;
}
}
【问题讨论】:
-
Chrome 是您的问题适用的唯一浏览器吗?
-
仅供参考:
-ms-high-contrast媒体查询仅适用于 IE 和 Edge Legacy。 -
感谢您的澄清,请随时写下您所有的 cmets 作为答案
标签: javascript css reactjs accessibility high-contrast