简体   繁体   English

防止Edge中的高对比度模式将背景添加到文本中

[英]Preventing high-contrast mode in Edge from adding background to text

I'm working to adjust some components so that they all function and look good in high-contrast mode. 我正在努力调整某些组件,以使其在高对比度模式下都能正常工作并看起来不错。 Edge seems to be adding a black background under all text that IE11 does not add. Edge似乎在IE11未添加的所有文本下添加了黑色背景。 I can't seem to find a way to target this background in CSS, or any other way to normalize the behavior between the two browsers. 我似乎找不到在CSS中以这种背景为目标的方法,或任何其他方法来规范这两种浏览器之间的行为。

For example, let's say I have the following: 例如,假设我有以下内容:

<div class="SelectedText">
  Text!
</div>

And let's say I assigned background-color: cyan; 假设我分配了background-color: cyan; and color: black; color: black; to the .SelectedText div. .SelectedText div。

In this scenario, IE11 renders it as expected with the div and text having the assigned colors. 在这种情况下,IE11使用div和具有指定颜色的文本按预期方式呈现它。 However, in Edge the div background and text are given the right colors, but the text itself gets a black background drawn behind it, making it unreadable black on black text. 但是,在Edge中,为div背景和文本指定了正确的颜色,但是文本本身在其后面绘制了黑色背景,因此在黑色文本上不可读。

The following image illustrates this problem occurring in the context of menu items with with basically the same markup described above. 下图说明了在菜单项的上下文中使用与上述基本相同的标记出现的此问题。

在此处输入图片说明

Is there any way to disable or target this extra background that Edge adds? 有什么方法可以禁用或定位Edge添加的额外背景吗?

Found the answer to this eventually. 最终找到了答案。 Setting -ms-high-contrast-adjust: none; 设置-ms-high-contrast-adjust: none; on the parent can disable the backgrounds that Edge puts behind text. 在父级上可以禁用Edge放置在文本后面的背景。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM