CSS - Change text color depending on background

前端 未结 2 1605
忘掉有多难
忘掉有多难 2020-12-07 04:31

I have a simple layout consisting of three full height divs and a fixed header bar.

2条回答
  •  暗喜
    暗喜 (楼主)
    2020-12-07 04:57

    You can use mix-blend-mode:difference

    body,
    html {
      padding: 0;
      margin: 0;
    }
    
    .header {
      position: fixed;
      width: 100%;
      height: 50px;
      margin: 20px;
      color:#fff;
      mix-blend-mode: difference;
    }
    
    .section1,
    .section2,
    .section3{
      background: black;
      height: 100vh;
      display: flex;
      align-items: center;
      justify-content: center;
      color: white;
    }
    
    .section2 {
      background: white;
      color:#000;
    }
    Header Content
    Section One Content
    Section Two Content
    Section Three Content

提交回复
热议问题