Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Having Issue on Inverting Black to White PNG

Tags:

css

I have a PNG file and I would like to invert the black color of the objects to White on hover.

I already tried is this

img:hover {
   -webkit-filter: grayscale(1) invert(1);
    filter: grayscale(1) invert(1);
 }
<img src="http://goproweb.ca/new/img/new/11.png">

This makes the objects grey, but I was hoping to make them to white.

like image 962
Behseini Avatar asked Feb 10 '16 20:02

Behseini


People also ask

How do I change a PNG from black to white?

Go to Edit > Edit Colors > Invert Colors.

Can you invert a PNG file?

An inverted PNG doesn't lose its sharpness, details, or color richness but it shows the image in a completely different way. You can see inverted photos in real life on old photographic films and photo negatives.

How do I change a PNG from black to white in Photoshop?

There are a few different ways that you can change a PNG from black to white in Photoshop. One way is to use the Levels tool. With the Levels tool, you can adjust the black point and the white point until the image is entirely white. Another way to change a PNG from black to white is to use the Selective Color tool.


1 Answers

I believe your issue is arising from using an image that is grey, rather than black. When this grey image is inverted, it just looks like a lighter color of grey.

Your code works fine, you just need to use a darker image to get the desired effect. Try swapping your image with this:

<img src="https://upload.wikimedia.org/wikipedia/commons/thumb/1/17/Yin_yang.svg/2000px-Yin_yang.svg.png" width="100px" height="100px">

Working fiddle with different image: https://jsfiddle.net/9f2cd2df/1/

like image 131
James Avatar answered Nov 11 '22 13:11

James