::selection 伪元素轮廓属性 [英] ::selection pseudo-element outline property
问题描述
他们声明 ::selection
选择器可以使用 outline 属性,但我无法让它工作.
They state that the ::selection
selector can use the outline property, but I haven't been able to get this to work.
如何使用此选择器正确影响outline?
How do I affect outline with this selector properly?
推荐答案
::selection
伪元素目前不在标准轨道上的任何 CSS 模块中.不应在生产环境中使用.
The
::selection
pseudo-element currently isn't in any CSS module on the standard track. It should not be used in production environments.
哪个浏览器支持这个伪元素上的哪些属性在今天基本上无关紧要.您可能无法获得一致的跨浏览器体验,因此您最好避免边缘细节并坚持每个浏览器支持的内容.
Which browser supports which properties on this pseudo-element is largely irrelevant today. You'll likely not get a consistent cross-browser experience, so you're probably better of avoiding the fringe details and stick to what each browser supports.
当 ::selection
在选择器规范中时 (2005 年 12 月),我们会读到:
When ::selection
was in the Selectors Specification (December 2005), we would read:
这些是应用于 ::selection
伪元素的 CSS 属性:color
、background
、cursor
(可选)、outline
(可选).::selection
上的 'background-image' 属性的计算值可能会被忽略.
These are the CSS properties that apply to
::selection
pseudo-elements:color
,background
,cursor
(optional),outline
(optional). The computed value of the 'background-image' property on::selection
may be ignored.
color
和 background-color
属性似乎是最受支持的,因为它们是唯一的非可选值.一些浏览器甚至支持 text-shadow
,尽管它没有在规范中列出.
The color
and background-color
properties appear to be the best supported since they were the only non-optional values. Some browsers even support text-shadow
, though it was not listed in the Specification.
我会避免尝试实现对其他任何跨浏览器的支持.最后,请记住,像这样的非标准功能将来可能会出现并消失.所以不要太执着于它.
I would avoid trying to achieve support for anything else cross-browser. Ultimately, keep in mind that non-standard features like this could up and vanish in the future. So don't get too attached to it.
实施和支持详情
这篇关于::selection 伪元素轮廓属性的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!