简体   繁体   English

* :: selection为什么不能为您提供正确的颜色?

[英]Why does *::selection not give you the correct colour?

I have Googled this but can't find any info on it. 我已经对此进行了Google搜索,但是找不到任何相关信息。

Say you set your page highlight colour to a nice orange : 假设您将页面突出显示颜色设置为漂亮的橙色

*::selection {
     background: #C44610;
 }

Why, when you highlight your page, does the background show as red , I swabbed this colour in photoshop and it gives me a hex value of #c24432 which is way off the orange I selected. 为什么当您突出显示页面时,背景是否显示为红色 ,我在photoshop中擦了擦此颜色,却给了我一个十六进制值#c24432,它与我选择的橙色值相去甚远。

I have tested this on Chrome. 我已经在Chrome上进行了测试。 In firefox I can't get the selection to work at all, it just gives me the default colour. 在firefox中,我根本无法使选择生效,它只是为我提供了默认颜色。

Any thoughts? 有什么想法吗?

For example you can edit this code: 例如,您可以编辑以下代码:

::selection{ background-color: #E13300; color: white; }
::moz-selection{ background-color: #E13300; color: white; }
::webkit-selection{ background-color: #E13300; color: white; }

Don't need the * 不需要*

Also will need the ::-moz-selection {} for Firefox 对于Firefox,还需要::-moz-selection {}

BTW, you shoulkd consider that since the selection color is a bit transparent, it changes depending on the background... 顺便说一句,您应该考虑到选择颜色有点透明,所以它会根据背景而变化...

Greetings from Argentina 来自阿根廷的问候

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

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