如何覆盖“-moz-user-select:none;”对子元素? [英] How do you override "-moz-user-select: none;" on a child element?

查看:235
本文介绍了如何覆盖“-moz-user-select:none;”对子元素?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

此问题禁用文本选择突出显示的CSS规则显示了以防止在元素上选择文本。一旦阻止选择,那么如何允许选择特定的子元素?例如

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

<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 规则不,这是正确的方法这样做?

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

推荐答案

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

作为未来参考,无论何时关心css规则的可能值,请检查 MDN

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

a href =https://developer.mozilla.org/en-US/docs/Web/CSS/user-select>此处是用户选择的MDN链接, code>。

Here is the MDN link for user-select.

这篇关于如何覆盖“-moz-user-select:none;”对子元素?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆