http://jigsaw.w3.org/css-validator/ 处的验证器表示“用户选择”的值“文本”无效。对于其中包含此代码的 css 规则:
user-select: text;
验证者说:
文本不是用户选择的值:文本文本
大概是因为这种行为,指定于(过时的)http://www.w3.org/TR/2000/WD-css3-userint-20000216#user-select :
This property is not inherited, but it does affect children in the same way that display: none does, it limits it. That is if an element is user-select: none, it doesn't matter what the user-select value is of its children, the element's contents or it's childrens contents cannot be selected.
此外,我只看到 w3.org 中那个过时的 css3 文档中指定的属性值“文本”:
http://www.w3.org/TR/2000/WD-css3-userint-20000216#user-select
而不是最新的:http://www.w3.org/TR/css3-ui/
此外,搜索“whatwg.org”不会产生任何结果。
如果 'user-select: text' 是有效的 css3,有什么想法吗?如果不是,应该用什么代替?
例如,当覆盖应用于文本容器和祖先容器的“user-select: none”规则时,将使用它。
最佳答案
你弄错了。 user-select:text
并不意味着它只会选择文本。它是 user-select
属性的默认值。 W3C这样描述:
The element's contents follow a standard text content selection model.
还有MDN syas 相同的东西:
-moz-none The text of the element and sub-elements cannot be selected, but selection can be enabled on sub-elements using
-moz-user-select:text
.
所以我认为这不会阻止选择图像或框。
据我所知 user-select:text 当你对大部分或所有元素使用 user-select:none
并且你有一个文本框或文本区域是一种输出并且你想要可选择复制和粘贴。
看来如果你使用 -webkit- 前缀它对我有用。我确定它也适用于 -moz- 前缀。测试这个 fiddle在您的浏览器中。我不知道为什么 user-select:text
在我的 Chrome 13 Mac 上不工作?
关于text - 如何在css3中得到 'user-select: text'的效果?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7355934/