-webkit-user-select:none 和 -ms-user-select:none 复制内容

-webkit-user-select:none and -ms-user-select:none copying the content

我正在尝试禁止选择具有特定 class 的 table 中的某些 <td>。在那个 class 的 CSS 文件中,我添加了

-webkit-user-select: none;  
-ms-user-select: none;      

但它们似乎都不起作用。仅在视觉上,那些 <td> 似乎没有被选中。但是,如果我复制并粘贴数据,这些单元格中的内容也会被复制。浏览器版本是 - IE 11 和 Chrome 43.0.2357.132 m

添加 -moz-user-select: none; 非常适合 Firefox。知道为什么它不适用于其余两个浏览器吗?

为确保行号未被复制,您可以使用标准 <ol> 标签:

<ol>
    <li>Can't select line number</li>
</ol>

要设置样式,请创建 a counter along with ::before 使其不 select。您可以通过此方法使用任何元素(不仅是 <ol>)。

带有额外样式的演示:http://jsfiddle.net/DerekL/ae2fggL5/


(Chrome) 行号显示为 selected,但您不能实际复制它们或单独 select 它们。


(Firefox) 无法在 Firefox 中 select 编辑行号。