CSS禁用文本选择 [英] CSS disable text selection
本文介绍了CSS禁用文本选择的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
目前,我已将其放在body标记中以禁用文本选择:
Currently, I have put this in the body tag to disable text selections:
body {
-webkit-user-select: none;
-moz-user-select: none;
-ms-user-select: none;
user-select: none;
}
但是,输入
和 textarea
框现在无法选择。
However, my input
and textarea
boxes are now unselectable. How can I only make these input elements selectable and the rest unselectable?
推荐答案
不要将这些属性应用于整个身体。将它们移动到类并将其应用到要禁用的元素select:
Don't apply these properties to the whole body. Move them to a class and apply that class to the elements you want to disable select:
.disable-select {
-webkit-user-select: none;
-moz-user-select: none;
-ms-user-select: none;
user-select: none;
}
这篇关于CSS禁用文本选择的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文