Invert colors of an image in CSS or JavaScript

后端 未结 4 506
慢半拍i
慢半拍i 2020-12-12 15:53

How do I invert colors of an image (jpg/png..) in either css if possible or javascript?

Previous related questions don\'t give enough detail.

4条回答
  •  长情又很酷
    2020-12-12 16:07

    Can be done in major new broswers using the code below

    .img {
        -webkit-filter:invert(100%);
         filter:progid:DXImageTransform.Microsoft.BasicImage(invert='1');
    }
    

    However, if you want it to work across all browsers you need to use Javascript. Something like this gist will do the job.

提交回复
热议问题