0

I have a background image, PNG, black on white with transparent white. I'm using it for background on otherwise empty <span> elements with spriting (background position and no repeat). The spans appear as if they have a black image on top of the document background color.

Is there a way, by CSS and/or HTML means, to make the black part of the background image appear in a color, say, in red?

The image is not mine, so replacing black with red statically won't work. Colorizing programmatically during run-time might work, but I was hoping there was a better way.

Targeting WebKit based browsers on iOS and Android. It's not on a website, it's inside a WebView type control inside an app.

EDIT:

.x {
  display: inline-block;
  width: 24px;
  height: 24px;
  background-repeat: no-repeat;
  background-image: url("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAoAAAAKAQMAAAC3/F3+AAAABlBMVEX///8AAABVwtN+AAAAAXRSTlMAQObYZgAAABhJREFUeF5FwjENAAAAg7Apwb/MfdB0ojoHYgB597y2UAAAAABJRU5ErkJggg==");
}
<span class="x"></span>

I want the black dot that comes from the image to be red instead. Or blue.

Temani Afif
  • 245,468
  • 26
  • 309
  • 415
Seva Alekseyev
  • 59,826
  • 25
  • 160
  • 281

0 Answers0