Reputation: 168269
I am trying to override the default setting for selection. I did
::selection{
background: grey;
}
and it looks like that takes effect when the window is not focused, but when it is focused, it does not have effect and the default color appears. It is not working. What is the correct way to do this so that is has effect irrespective of the focus?
Edit I think I was wrong. I want to change the color of the selected text in <input>
tag. How can I do that?
Upvotes: 0
Views: 50
Reputation: 157424
It is the default browser behavior which you cannot change, when window is not focused, the selected color changes to grey, may be it denotes that the text cannot be copied (kinda disabled selection), so we cannot control that color
Example 2
Upvotes: 1
Reputation: 35582
Should Work fine, See this demo. the problem seems to be due to something else
::selection
{
background: grey;
}
::-moz-selection
{
background: grey;
}
Upvotes: 1
Reputation: 298582
You're probably using Firefox, which needs the -moz
prefix:
::selection {
color: fireBrick;
}
::-moz-selection {
color: fireBrick;
}
Demo: http://jsfiddle.net/N4AUY/
Note that you cannot group these together. One of these won't work, so the whole rule block breaks.
Upvotes: 1