+
82
-

div如何禁止用户选择文字?

css

div如何禁止用户选择文字?

网友回复

+
1
-

两种方式实现

一、css方式

/* css style: */
html,body{
-moz-user-select: none;
-khtml-user-select: none;
user-select: none;
}

二,html方式

<div unselectable="on" onselectstart="return false;" style="-moz-user-select:none;">bfw</div>
unselectable针对IE
onselectstart针对Chrome、Safari
-moz-user-select是firefox专有的

by bfwui
+
0
-

还有针对移动端ios和andriod手机

/* css style: */
html,body{
-moz-user-select: none;
-khtml-user-select: none;
-webkit-user-select:none;
user-select: none;
}



by ppzhuzhu
我知道答案,我要回答