0

I have a svg created in a div thanks to ::after{content: url(mysvg)}. The svg is black by default. I want to make it green. I have tried to add fill="currentColor" to its inline code, to add color: green, fill: green, etc. Nothing works. How to change its color?

Here is my code:

.mydiv{
  color: green;
}

.mydiv::after {
  content: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 32 32'><polygon points='16 1.73 20.64 11.13 31 12.63 23.5 19.94 25.27 30.27 16 25.39 6.73 30.27 8.5 19.94 1 12.63 11.37 11.13 16 1.73' stroke-linecap='round' stroke-linejoin='round' stroke-width='2'/></svg>");
  background-size: contain; 
  display: inline-block;
  width: 32px;
  height: 32px;
}

Please find this codepen in case it might be helpful: https://codepen.io/MonsieurLeland/pen/PoZyVdN

DoneDeal0
  • 5,273
  • 13
  • 55
  • 114

0 Answers0