gpt4 book ai didi

css - 网络工具包 : Css text selection styling can not make background white?

转载 作者:技术小花猫 更新时间:2023-10-29 11:09:48 24 4
gpt4 key购买 nike

因此,文本选择通过::selection 伪元素设置了样式,以覆盖浏览器的默认选择颜色。但对我来说,似乎禁止使用白色作为选择背景色,而选择灰色、不透明的颜色。

::selection      { color: black;  background: white; }
::-moz-selection { color: black; background: white; }

body {
background: black;
color: white;
}
So selecting me is supposed to invert the text and background colors. But the selected text background color is not white, but grey.

为什么这创建一个完美的白色背景?相反,它显示灰色背景 (#989898)

Css selection does not accept white background

另请参阅 https://jsfiddle.net/duk3/hzodm1sh/ 上的此片段

最佳答案

好的,所以关注 this question我找到了答案:

For some reason Chrome forces it to be semi-transparent. However, you can get around this by setting the background using rgba. I have set the alpha value to be just 0.01 less than 1.

::selection { color: black;  background: rgba(255, 255, 255, 0.996);
; }

body {
background: black;
color: white;
}
Selecting me DOES invert the text and background colors. Well, almost, but it looks like perfect white.

关于css - 网络工具包 : Css text selection styling can not make background white?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32820767/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com