禁用文本选择突出显示的问题CSS 规则显示了如何防止在元素上选择文本。一旦你阻止了选择,你怎么能允许选择一个特定的子元素呢?
例如,
<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
无效。这样做的正确方法是什么?