HTML如何防止有人突出显示div中的文本?

时间:2011-08-17 10:29:31

标签: javascript html

首先是的,我找到了这个链接:

Is there a way to make text unselectable on an HTML page?

但它似乎对我不起作用。我有很多包含文本的div,制作一个自定义表。当用户使用ctrl并点击多行时,表内容也会突出显示。当我希望滚动表的溢出时,这会导致问题。

2 个答案:

答案 0 :(得分:0)

您可以使用此CSS:

.unselectable {
   user-select: none;
}

答案 1 :(得分:0)

使用CSS解决此问题:

body {
    -webkit-user-select: none; /* Webkit */
    -moz-user-select: none; /* Firefox */
    -ms-user-select: none; /* IE 10 */
    /* Currently not supported in Opera but will be soon */
    -o-user-select: none;
    user-select: none;
}