css - 如何使用 CSS 在 Mozilla Firefox 中启用子输入文本选择?

标签 css firefox webkit gecko textselection

让我们考虑以下场景。我有以下页面,其中所有呈现的元素都必须是不可选择的。

<html>
<head>
    <style type="text/css">
        body {
            -webkit-user-select: none;
            -moz-user-select: none;
        }
        div {
            border: solid 1px green;
            padding: 5px;
        }
    </style>
</head>
<body>
    <div>
        Lorem ipsum dolor sit amet, consectetuer adipiscing elit, sed diam nonummy
        nibh euismod tincidunt ut laoreet dolore magna aliquam erat volutpat.
        Ut wisi enim ad minim veniam, quis nostrud exerci tation ullamcorper
        suscipit lobortis nisl ut aliquip ex ea commodo consequat. Duis autem
        vel eum iriure dolor in hendrerit in vulputate velit esse molestie consequat
    </div>
    <div>
        <input type="text" value="You can select the text from me" />
        <textarea>
            And me too.
        </textarea>
    </div>
</body>
</html>

inputtextarea 文本在 Google Chrome 中仍然可以选择,但在 Firefox 中文本不可选择。我已经尝试过以下方法:

input, textarea {
    -moz-user-select: text !important;
}

而且......它根本不起作用,因为(据我所知)inputtextarea 嵌套在文档正文元素中,而这已经不是可选择的。那么,是否可以使用 CSS 在 Firefox 中启用嵌套用户输入元素的文本选择?

感谢您的建议。

最佳答案

是否:

    body {
        -webkit-user-select: none;
        -moz-user-select: -moz-none; /* changed from none to -moz-none */
    }
    input, textarea {
        -moz-user-select: text;
    }

工作?

参见 this page .

关于css - 如何使用 CSS 在 Mozilla Firefox 中启用子输入文本选择?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2809498/

相关文章:

javascript - 除了 page-break-after 和 page-break-before 之外的 Css 打印控制

html - 无法使页脚粘在底部

html - 如何在 Firefox 的 contentEditable div 中禁用 <br type ="_moz"

linux - 在不同的显示器上启动两次 firefox

google-chrome - 将本地 WebSQL/IndexedDB 数据库与 'pre-built' 数据库文件同步?

javascript - 即使在调整大小后也下载原始 Canvas

html - 选项卡不会在没有 javascript 的情况下将容器包装在解决方案上

javascript - 在 JavaScript 中打开新的浏览器窗口而不使其处于事件状态

javascript - 如何检测设备模式仿真?

css - 复杂选择器在最后一个闪烁版本 :nth-child(2):nth-last-child(2){} 中不起作用