我有这段代码,可以在Internet Explorer和Mozilla Firefox中正常运行,但是在Google Chrome上却无法运行,这是基本的CSS ::selection选择器。随附的是该问题的说明:
所需结果:(IE,Firefox)

怎么了:(Chrome)

这仅在Google Chrome浏览器中发生,我将在此处尝试的代码附加为:
::-moz-selection {
background-color: orange;
color: white;
}
::selection {
background-color: orange;
color: white;
}
::-webkit-selection {
background-color: orange;
color: white;
}Run Code Online (Sandbox Code Playgroud)
<ol>
<li>Hello World!</li>
<li>What's up?</li>
</ol>Run Code Online (Sandbox Code Playgroud)
::-webkit-selection 似乎没有解决问题,但还有另一种解决方法:
::-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;
}Run Code Online (Sandbox Code Playgroud)
<ol>
<li><span>Hello World!</span></li>
<li><span>What's up?</span></li>
</ol>Run Code Online (Sandbox Code Playgroud)