How can I invert color using CSS?

前端 未结 3 1806
没有蜡笔的小新
没有蜡笔的小新 2020-12-05 01:37

HTML

inverted color

CSS

div {
    background-color: #f00;
}
p { 
    color:         


        
3条回答
  •  离开以前
    2020-12-05 02:05

    Here is a different approach using mix-blend-mode: difference, that will actually invert whatever the background is, not just a single colour:

    div {
      background-image: linear-gradient(to right, red, yellow, green, cyan, blue, violet);
    }
    p {
      color: white;
      mix-blend-mode: difference;
    }

    Lorem ipsum dolor sit amet, consectetur adipiscit elit, sed do

提交回复
热议问题