Last active
June 11, 2021 05:55
-
-
Save FlandreDaisuki/d480bec1a68a84c228ae73ed452424b4 to your computer and use it in GitHub Desktop.
Webkit ignores the CSS rule that its selector list contains unknown pseudo element selector
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<html lang="en"> | |
<head> | |
<meta charset="UTF-8"> | |
<meta http-equiv="X-UA-Compatible" content="IE=edge"> | |
<meta name="viewport" content="width=device-width, initial-scale=1.0"> | |
<title>Webkit Selector List Bug</title> | |
</head> | |
<body> | |
<input type="range" min="0" max="100" /> | |
<p>Open the devtool & see the rule apply on the slider thumb shadow DOM</p> | |
<p>According to <a target="_blank" href="https://developer.mozilla.org/en-US/docs/Learn/CSS/Building_blocks/Selectors">MDN</a>, it | |
says <quote>"When you group selectors in this way, if any selector is invalid the whole rule will be ignored" | |
</quote>.</p> | |
<p>There is a modern solution to solve: <a target="_blank" href="https://web.dev/css-is-and-where/">New CSS functional pseudo-class selectors :is() and :where()</a>. However, it is not work on my latest Firefox & Chrome.</p> | |
<style> | |
/* https://css-tricks.com/styling-cross-browser-compatible-range-inputs-css/ */ | |
input[type=range]::-webkit-slider-thumb { | |
--rule: 'input[type=range]::-webkit-slider-thumb'; | |
} | |
input[type=range]::-moz-range-thumb { | |
--rule: 'input[type=range]::-moz-range-thumb'; | |
} | |
input[type=range]::-webkit-slider-thumb, | |
input[type=range]::-moz-range-thumb { | |
--rule: 'input[type=range]::-webkit-slider-thumb, input[type=range]::-moz-range-thumb'; | |
} | |
::-webkit-slider-thumb, | |
::-moz-range-thumb { | |
--rule: '::-webkit-slider-thumb, ::-moz-range-thumb'; | |
} | |
</style> | |
<style> | |
:is(input[type=range]::-webkit-slider-thumb, input[type=range]::-moz-range-thumb) { | |
--modern-rule: ':is(input[type=range]::-webkit-slider-thumb, input[type=range]::-moz-range-thumb)'; | |
} | |
:where(input[type=range]::-webkit-slider-thumb, input[type=range]::-moz-range-thumb) { | |
--modern-rule: ':where(input[type=range]::-webkit-slider-thumb, input[type=range]::-moz-range-thumb)'; | |
} | |
input[type=range]:is(::-webkit-slider-thumb, ::-moz-range-thumb) { | |
--modern-rule: 'input[type=range]:is(::-webkit-slider-thumb, ::-moz-range-thumb)'; | |
} | |
input[type=range]:where(::-webkit-slider-thumb, ::-moz-range-thumb) { | |
--modern-rule: 'input[type=range]:where(::-webkit-slider-thumb, ::-moz-range-thumb)'; | |
} | |
</style> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment