我有网站,我第一次设置
::selection
{
background: transparent;
}
::-moz-selection
{
background: transparent;
}
*
{
-moz-user-select: none;
-khtml-user-select: none;
-webkit-user-select: none;
-o-user-select: none;
user-select: none;
}
Run Code Online (Sandbox Code Playgroud)
(仅仅是为了艺术效果,不是因为我试图阻止人们复制某些东西.)
但后来,我希望用户能够从textarea中选择文本..
我能够再次看到选择,
#commentarea::selection
{
background: #070707;
}
#commentarea::-moz-selection
{
background: #070707;
}
#commentarea
{
-moz-user-select: element;
-khtml-user-select: element;
-webkit-user-select: element;
-o-user-select: element;
user-select: element;
}
Run Code Online (Sandbox Code Playgroud)
但是如果用户从textarea中选择了某些内容,则无法通过单击某处取消选择该内容.您只能通过移动插入符(使用箭头键)取消选择文本.
这是为什么?我该如何防止这种情况?
改变
#commentarea
{
-moz-user-select: element;
-khtml-user-select: element;
-webkit-user-select: element;
-o-user-select: element;
user-select: element;
}
Run Code Online (Sandbox Code Playgroud)
到
#commentarea {
-webkit-user-select: text;
-moz-user-select: text;
-khtml-user-select: text;
-webkit-user-select: text;
-o-user-select: text;
}
Run Code Online (Sandbox Code Playgroud)
演示: http: //jsfiddle.net/dWjPQ/1/