I want to change an area to max overflow:scroll only if ::-webkit-scrollbar-thumb
is supported.
Is that possible somehow in pure CSS? As it seems @supports
only checks rules, no selectors.
I want to change an area to max overflow:scroll only if ::-webkit-scrollbar-thumb
is supported.
Is that possible somehow in pure CSS? As it seems @supports
only checks rules, no selectors.
You can now use @supports selector()
to target pseudoelements. Here is a relevant example for your use case:
@supports selector(::-webkit-scrollbar-thumb) {
.scroll-container {
overflow: scroll
}
}
Please see this JSFiddle, which demonstrates browser support for ::-webkit-scrollbar-thumb
in
but not
As of December 2020, browser support for @supports selector
is roughly 72%.
You are correct. @supports
only deals with property-value combinations. The only way you could do this in pure CSS is with a CSS hack targeting browsers that support ::-webkit-scrollbar-thumb
. (Not enough browsers support @supports
for it to be useful in checking support for ::-webkit-scrollbar-thumb
anyway.)
Adding up to the previous answer, you can just write the pseudo selector, if a browser doesnt support the prop, it will skip the css declaration.
For example:
li::marker{color:blue}
won't be seen by older browsers.
This is what I used to identify Webkit browsers. It's the most specific pseudo selector I could find that no other engine seems to have (yet):
CSS.supports(`selector(input[type='time']::-webkit-calendar-picker-indicator)`)