Created
November 10, 2022 19:01
-
-
Save joduplessis/8ccf53766e7b3d2dd4940af9cfb1554c to your computer and use it in GitHub Desktop.
CSS for highlighting all previous stars in a rating component (without JS!).
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
.rate { | |
width: fit-content; | |
} | |
.rate__star { | |
color: var(--f-color-text-weakest); | |
padding: var(--f-size-1); | |
} | |
.rate__star:hover { | |
color: var(--f-color-text-weaker); | |
} | |
.rate:hover > .rate__star:not(:hover) { | |
color: var(--f-color-text-weaker); | |
} | |
.rate:hover .rate__star:hover ~ .rate__star { | |
color: var(--f-color-text-weakest); | |
} | |
.rate:hover .rate__star:hover ~ .rate__star svg { | |
fill: var(--f-color-text-weakest) !important; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Just replace the vars!