这个伪元素应用于什么?
What is this pseudo-element applied to?
考虑一下我的 css 有这个:
::-webkit-scrollbar {
width: 5px;
height: 5px;
}
这适用于什么?它不适用于 html
或 body
。但是为了什么?
我试图在某个库(handsontable)的组件上设置滚动条的样式,但它呈现得很有趣,因为它的 JS 代码正在从 某处 读取滚动条大小。
上面的 css 解决了这个问题。但随后它会在应用程序的任何地方设置滚动条大小,这是不可取的。我正在寻找解决方法。如果我这样做:
html::-webkit-scrollbar {
width: 5px;
height: 5px;
}
或与作为组件父项的任何 class 相同,我没有得到结果。
这个:
::-webkit-scrollbar {
width: 5px;
height: 5px;
}
与此相同:
*::-webkit-scrollbar {
width: 5px;
height: 5px;
}
所以它适用于所有元素。
If a universal selector represented by *
is not the only component
of a sequence of simple selectors or is immediately followed by a
pseudo-element, then the *
may be omitted and the universal
selector's presence implied.
考虑一下我的 css 有这个:
::-webkit-scrollbar {
width: 5px;
height: 5px;
}
这适用于什么?它不适用于 html
或 body
。但是为了什么?
我试图在某个库(handsontable)的组件上设置滚动条的样式,但它呈现得很有趣,因为它的 JS 代码正在从 某处 读取滚动条大小。
上面的 css 解决了这个问题。但随后它会在应用程序的任何地方设置滚动条大小,这是不可取的。我正在寻找解决方法。如果我这样做:
html::-webkit-scrollbar {
width: 5px;
height: 5px;
}
或与作为组件父项的任何 class 相同,我没有得到结果。
这个:
::-webkit-scrollbar {
width: 5px;
height: 5px;
}
与此相同:
*::-webkit-scrollbar {
width: 5px;
height: 5px;
}
所以它适用于所有元素。
If a universal selector represented by
*
is not the only component of a sequence of simple selectors or is immediately followed by a pseudo-element, then the*
may be omitted and the universal selector's presence implied.