你如何在子元素上覆盖“-moz-user-select:none;”?

时间:2022-07-06 17:07:46

This question CSS rule to disable text selection highlighting shows how to prevent text selection on an element. Once you have prevented selection, how can you then allow selection for a specific child element? eg

此问题禁用文本选择突出显示的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;
}

The .no-select rule above works, but my attempt at a .select rule does not, what is the correct way to do this?

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

1 个解决方案

#1


17  

Try -moz-user-select: text instead of all.

尝试-moz-user-select:text而不是all。

As a future reference, whenever concerned about the possible values for a css rule, check a site like MDN.

作为未来的参考,只要关注css规则的可能值,请检查像MDN这样的站点。

Here is the MDN link for user-select.

这是用户选择的MDN链接。

#1


17  

Try -moz-user-select: text instead of all.

尝试-moz-user-select:text而不是all。

As a future reference, whenever concerned about the possible values for a css rule, check a site like MDN.

作为未来的参考,只要关注css规则的可能值,请检查像MDN这样的站点。

Here is the MDN link for user-select.

这是用户选择的MDN链接。