CSS : selection伪元素是否可以有渐变背景?
CSS : Is it possible to have a gradient background on the selection pseudo element?
我正在尝试向选择伪元素添加渐变背景。到目前为止,我已经尝试了这段代码,它只是返回一个白色背景。
::-moz-selection {
background: -moz-linear-gradient(-45deg, $degrade-min 0%, $degrade-max 100%); /* FF3.6-15 */
background: -webkit-linear-gradient(-45deg, $degrade-min 0%,$degrade-max 100%); /* Chrome10-25,Safari5.1-6 */
background: linear-gradient(135deg, $degrade-min 0%,$degrade-max 100%); /* W3C, IE10+, FF16+, Chrome26+, Opera12+, Safari7+ */
color:white;
}
::selection {
background: -moz-linear-gradient(-45deg, $degrade-min 0%, $degrade-max 100%); /* FF3.6-15 */
background: -webkit-linear-gradient(-45deg, $degrade-min 0%,$degrade-max 100%); /* Chrome10-25,Safari5.1-6 */
background: linear-gradient(135deg, $degrade-min 0%,$degrade-max 100%); /* W3C, IE10+, FF16+, Chrome26+, Opera12+, Safari7+ */
color:white;
}
所以我想知道这是否不可能?
So i'm wondering if maybe that's just not possible ?
https://drafts.csswg.org/css-pseudo-4/#highlight-styling:
The following properties apply to the highlight pseudo-elements:
color
background-color
cursor
caret-color
outline
and its longhands
text-decoration
and its associated properties
text-emphasis-color
text-shadow
因为根据 CSS,渐变被认为是 图像 ,所以答案是:否,因为 background-image
属性 是不属于上述列表,因此根据规范这是不可能的。
我正在尝试向选择伪元素添加渐变背景。到目前为止,我已经尝试了这段代码,它只是返回一个白色背景。
::-moz-selection {
background: -moz-linear-gradient(-45deg, $degrade-min 0%, $degrade-max 100%); /* FF3.6-15 */
background: -webkit-linear-gradient(-45deg, $degrade-min 0%,$degrade-max 100%); /* Chrome10-25,Safari5.1-6 */
background: linear-gradient(135deg, $degrade-min 0%,$degrade-max 100%); /* W3C, IE10+, FF16+, Chrome26+, Opera12+, Safari7+ */
color:white;
}
::selection {
background: -moz-linear-gradient(-45deg, $degrade-min 0%, $degrade-max 100%); /* FF3.6-15 */
background: -webkit-linear-gradient(-45deg, $degrade-min 0%,$degrade-max 100%); /* Chrome10-25,Safari5.1-6 */
background: linear-gradient(135deg, $degrade-min 0%,$degrade-max 100%); /* W3C, IE10+, FF16+, Chrome26+, Opera12+, Safari7+ */
color:white;
}
所以我想知道这是否不可能?
So i'm wondering if maybe that's just not possible ?
https://drafts.csswg.org/css-pseudo-4/#highlight-styling:
The following properties apply to the highlight pseudo-elements:
color
background-color
cursor
caret-color
outline
and its longhands
text-decoration
and its associated properties
text-emphasis-color
text-shadow
因为根据 CSS,渐变被认为是 图像 ,所以答案是:否,因为 background-image
属性 是不属于上述列表,因此根据规范这是不可能的。