Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Selection changes color when Firefox loses focus

I'm setting the selection background color via CSS:

::selection {
  background:#cc0000;
  color:#fff;
}

::-moz-selection {
  background:#cc0000;
  color:#fff;
}

On most browsers when the focus is somewhere else (like an IFrame), the selection color will stay the same, e.g.:

enter image description here

but on Firefox it won't:

enter image description here

You can see this in action on jsFiddle here.

How can I get Firefox to set the selection color in this case? Is this a bug?

like image 698
paleozogt Avatar asked Oct 23 '22 23:10

paleozogt


1 Answers

How can I get Firefox to set the selection color in this case?

Unfortunately, there doesn't appear to be a way to do so.

Is this a bug?

Nobody (including Mozilla themselves?) can say for sure; this was never specified while ::selection was still in the CSS3 spec. I can't find any information on MDN or bug reports on bugzilla.mozilla.org on this either. but I did find this bug report, which has apparently been left unresolved since being reported in 2010.

This may be clarified in the future, e.g. if ::selection returns in UI 4.

like image 67
BoltClock Avatar answered Oct 26 '22 22:10

BoltClock