I am using a rating system that used to display Font Awesome star (and half star) icons, which I recently switched to headphone icons. Font awesome provides a half-star icon but doesn't provide a half-headphone icon. So I had to use CSS to only display half an icon (full-opacity) and the other half with less opacity. This is how I did it:
background: linear-gradient(to right, rgb(206, 55, 72) 50%, rgba(206, 55, 72, 0.28) 50%);
-webkit-background-clip: text;
-webkit-text-fill-color: transparent;
Example (see the red icons below for a rating of 4.5 headphones):
Problem is, I also use this same rating in other places, where the font color is different. But because I'm defining a specific RGB value, it's using the same color across the entire site for my half-headphone.
Check it out:
Can I "inherit" the color while using linear-gradient and only affect the opacity of the icon?
Such as:
background: linear-gradient(to right, inherit 50%, rgba(inherit, 0.28) 50%);
Or is there another approach to this?
Thank you.