【发布时间】:2017-08-13 11:11:38
【问题描述】:
== 在 60.0.3112.90 版本中由 Chrome 修复 ==
-Chrome 错误-
好的,所以我一直在从事一个具有 CSS 行号的项目。当用户突出显示/选择文本时,数字也会突出显示/选择。幸运的是 :before 内容没有被复制,但它仍然让我烦恼。有没有办法解决这个问题。
注意:Pre 是 contenteditable='true'
我尝试过的:
user-select: none;
也一样
pre code:before::selection {
background: transparent;
}
这是一些示例代码:
<pre contenteditable='true'><code>bla</code><code>bla</code><code>bla</code></pre>
<style>
pre {
margin: 0px;
outline: none;
}
pre code {
display: block;
color: #a9b7c6;
counter-increment: line;
}
pre code:before {
content: '\00a0'counter(line)'\00a0';
margin-right: 2px;
border-right: solid #4b4b4b 1px;
}
</style>
现在的样子:
它应该是什么样子:
【问题讨论】:
-
我认为之前实际上使元素无法选择。你的情况如何相反
-
我完全不知道,文本复制功能很好,但看起来很烦人。
-
Chrome 错误报告链接:bugs.chromium.org/p/chromium/issues/…