CSS选择颜色在Chrome上的显示方式异常 [英] CSS selection color behaving strangely on Chrome

查看:21
本文介绍了CSS选择颜色在Chrome上的显示方式异常的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用CSS :: selection 伪元素来更改网站的选择颜色.

I'm trying to change the selection color of my website using the CSS ::selection pseudoelement.

此jsFiddle 中可以看到,该文本被认为具有完全黑色的背景色已选择.在Firefox上,就是这种情况.

As seen in this jsFiddle, the text is supposed to have a totally black background color when being selected. On Firefox, this is the case.

但是,在Chrome上,颜色不是绝对是黑色. Chrome似乎在摆弄我的颜色.

However, on Chrome, the color is not absolutely black. Chrome seems to be fiddling with my colors.

如果您在选择时将文本保留为黑色,则可以看到此内容:在Firefox上,它变得不可见,但在Chrome上您仍然可以看到它.

You can see this if you leave the text black while selecting: on Firefox, it becomes invisible, while on Chrome you can still see it.

我注意到我在使用的其他背景色上有这种影响:它们在Chrome上总是有点不正常.在我看来,好像添加了一点红色.

I've noticed this effect on other background colors that I was using: They were always a bit off on Chrome. It seems to me like a bit of red was added.

如何在Chrome上获得想要的真实颜色?

How can I get the true colors that I want on Chrome?

推荐答案

可能完全阻止您尝试执行的操作,似乎Chrome会更改所选内容的背景色的不透明度(如果为1).您可以作弊通过将不透明度设置为非常接近1,例如( background-color:rgba(0,0,0,.99).

Possibly to prevent exactly what you are trying to do, it seems like Chrome will change the opacity of the background color of the selection if it's 1. You can cheat this by setting the opacity very close to 1 like (background-color: rgba(0,0,0,.99).

http://jsfiddle.net/ExplosionPIlls/a3gfR/5/

这篇关于CSS选择颜色在Chrome上的显示方式异常的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆