How can I generate the opposite color according to current color?

前端 未结 11 661
北海茫月
北海茫月 2020-11-28 01:53

I\'m trying to create a color opposite of current color. I mean if current color is black, then I need to generate white.

Actually I have a text

11条回答
  •  感动是毒
    2020-11-28 02:27

    It is possible to convert a HEX color using the snippets

    function invertColor(color) {
          return '#' + ("000000" + (0xFFFFFF ^ parseInt(color.substring(1),16)).toString(16)).slice(-6);
      }
    

提交回复
热议问题