Change div color on parents background-color

前端 未结 1 1329
爱一瞬间的悲伤
爱一瞬间的悲伤 2020-12-07 05:21

I am trying to make a cube change based on its background color. I hoped this was possible by giving an element a bit of a transparent background and a filter to invert the

1条回答
  •  遥遥无期
    2020-12-07 06:09

    Maybe you are looking for mix-blend-mode:

    .cube {
      position: fixed;
      height: 50px;
      width: 50px;
      left: calc( 50vw - 25px);
      bottom: 50px;
      background-color: RGBA(255, 255, 255);
      mix-blend-mode: difference;
    }
    
    .section {
      height: 600px;
      width: 100vw;
    }
    
    .section1 {
      background-color: #AAAAFF;
    }
    
    .section2 {
      background-color: #FFAAAA;
    }
    
    .section3 {
      background-color: #AAFFAA;
    }

    0 讨论(0)
提交回复
热议问题