Created
August 6, 2019 04:56
-
-
Save dfkaye/f5251719f50e1cdac32c287a4eca08a5 to your computer and use it in GitHub Desktop.
CSS relative selectors
This file contains 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
/* 5 Aug 2019 */ | |
/* https://twitter.com/dfkaye/status/1158602465345884160 */ | |
/* | |
* Figure out why there are no CSS selectors for the following and - suddenly - you will "get" CSS: | |
* | |
* - previous adjacent sibling | |
* - previous general sibling | |
* - direct ancestor (parent) | |
* - general ancestor | |
*/ | |
/* prompted by this thread */ | |
/* David Khoursid, 1 Aug 2019 */ | |
/* https://twitter.com/DavidKPiano/status/1157019363255508992 */ | |
.red + .blue /*(adjacent subsequent sibling)*/ | |
.red ~ .blue /*(general subsequent sibling)*/ | |
.red > .blue /*(direct descendent)*/ | |
/* snark removed here... */ | |
.red .blue /*(general descendant - any level)*/ | |
/* follow-up is interesting */ | |
/* https://twitter.com/DavidKPiano/status/1157019363255508992 */ | |
.red > * > .blue /*(grandchild)*/ | |
.red * .blue /*(descendant but not direct)*/ | |
/* and then... */ | |
.red ~ * > .blue /*(niece or nephew)*/ | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment