I have a poll system and I want answers for this poll to be colored. For example: If it\'s 10% it would be red, if 40% it would be yellow and if 80% it would be green, so I
I know this is originally an old javascript question, but I got here searching for CSS only solution, so maybe it will help others equally: It's actually quite simple:
Use the percentage as a HSL color value!
Red to Green spans H from 0 to 128.(so you can pump the percentage up by 1.2 if you want). Example:
background-color:hsl(perc,100%,50%);
Where perc is just the number, without the % sign.