【问题标题】:How do you override "-moz-user-select: none;" on a child element?你如何覆盖“-moz-user-select:none;”在子元素上?
【发布时间】:2013-05-12 02:47:31
【问题描述】:

问题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 规则无效。这样做的正确方法是什么?

【问题讨论】:

    标签: css cross-browser textselection


    【解决方案1】:

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

    作为将来的参考,每当关注 CSS 规则的可能值时,请查看MDN 之类的网站。

    Hereuser-select 的 MDN 链接。

    【讨论】:

      猜你喜欢
      • 2020-08-11
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多