你如何覆盖“-moz-user-select:none;”在一个儿童元素?

时间:2013-05-17 02:23:38

标签: css cross-browser textselection

此问题CSS rule to disable text selection highlighting显示如何阻止对元素进行文本选择。一旦阻止了选择,那么如何允许选择特定的子元素?例如

<div class="no-select">
    <p>some text that cannot be selected</p>
    <p class="select">some text that can be selected</p>
    <p>some text that cannot be selected</p>
</div>

table.no-select{
-webkit-touch-callout: none;
-webkit-user-select: none;
-khtml-user-select: none;
-moz-user-select: none;
-ms-user-select: none;
user-select: none;
}

td.select{-webkit-touch-callout: all !important;
-webkit-user-select: all !important;
-khtml-user-select: all !important;
-moz-user-select: all !important;
-ms-user-select: all !important;
user-select: all !important;
}

上面的.no-select规则有效,但我对.select规则的尝试没有,这样做的正确方法是什么?

1 个答案:

答案 0 :(得分:17)

尝试使用-moz-user-select: text代替all

作为未来参考,只要关注css规则的可能值,请检查MDN之类的网站。

Hereuser-select的MDN链接。