小编Esh*_*ein的帖子

带有 CSS "user-select=none" 的元素的文本如果位于元素之间,则会被复制

看看这个片段:

.noselect {
  -webkit-touch-callout: none; /* iOS Safari */
    -webkit-user-select: none; /* Safari */
     -khtml-user-select: none; /* Konqueror HTML */
       -moz-user-select: none; /* Firefox */
        -ms-user-select: none; /* Internet Explorer/Edge */
            user-select: none; /* Non-prefixed version, currently
                                  supported by Chrome and Opera */
}
Run Code Online (Sandbox Code Playgroud)
<p>
  Selectable text.
</p>
<p class="noselect">
  Unselectable text.
</p>
<p>
  Selectable text.
</p>
Run Code Online (Sandbox Code Playgroud)

现在三次单击第一行,然后复制。将其粘贴到任何地方,您将能够看到“不可选择的文本”。也会被复制。这只发生在 Chrome 上。有谁知道为什么会发生这种情况以及有什么方法可以解决它?

css google-chrome textselection

5
推荐指数
1
解决办法
1193
查看次数

标签 统计

css ×1

google-chrome ×1

textselection ×1