CSS :: selection doesn't work in google chrome
I have this code that works fine in Internet Explorer and Mozilla Firefox, but it doesn't work in Google Chrome, it is the main CSS selector ::selection
. An example of the problem is attached:
Desired Output: (IE, Firefox)
What's wrong: (Chrome)
This only happens in Google Chrome, I am attaching the code I tried here:
::-moz-selection {
background-color: orange;
color: white;
}
::selection {
background-color: orange;
color: white;
}
::-webkit-selection {
background-color: orange;
color: white;
}
<ol>
<li>Hello World!</li>
<li>What up?</li>
</ol>
+3
source to share
3 answers
::-webkit-selection
doesn't seem to fix the problem, but there is another way:
::-moz-selection {
background-color: orange;
color: white;
}
::selection {
background-color: orange;
color: white;
}
ol {
-webkit-user-select: none;
-moz-user-select: none;
-ms-user-select: none;
}
ol span {
-webkit-user-select: all;
-moz-user-select: all;
-ms-user-select: all;
}
<ol>
<li><span>Hello World!</span></li>
<li><span>What up?</span></li>
</ol>
+4
source to share