cssmenumix-blend-mode

Mix-blend-mode not affecting any component


I tried searching the web for various answers and tried everything that solved other people problem, but my CSS just doesn't want to cooperate.

Here you can find a JSFiddle where I recreated the issue: I would like the side navigation to be visible on the black sections too.

HTML
<div class="sidenav">
  <a href="#" class="selected">Section 1</a>
  <a href="#">Section 2</a>
  <a href="#">Section 3</a>
</div>

<div class="content">
  <div>
    <p>Some text<p>
  </div>
  <div class="blk">
    <p>Some text<p>
  </div>
  <div>
    <p>Some text<p>
  </div>
</div>


CSS
.sidenav {
  width: auto;
  position: fixed;
  z-index: 1;
  top: 150px;
  padding: 8px 0;
}

.sidenav a {
  clear: both;
  float: left;
  position: relative;
  left: -20%;
  padding: 10px;
  margin-bottom: 15px;
  transition: 0.3s;

  text-decoration: none;
  text-align: right;
  font-size: 24px;

  border-style: solid;
  border-width: 2px;
  border-color: #0D0D0D;
  border-radius: 0 5px 5px 0;

  color: #0D0D0D;
  mix-blend-mode: difference;
}

.blk {
  background-color: #0d0d0d;
  color: #ffffff;
}

Solution

  • did you want something like this?

    html {
      scroll-behavior: smooth;
      background: #fff;
    }
    
    body {
      margin: 0;
      padding: 0;
      width: 100%;
      max-width: 100%;
    
      background-color: #ffffff;
      color: #0d0d0d;
    }
    
    /**********************************************/
    
    .section {
      width: 100vw;
      max-width: 100%;
      background-color: #ffffff;
      text-align: center;
    
      margin: 0;
      padding: 15vh 0;
      position: relative;
    }
    
    .blk {
      background-color: #0d0d0d;
      color: #ffffff;
    }
    
    /**********************************************/
    
    .sidenav {
      width: auto;
      position: fixed;
      z-index: 1;
      top: 150px;
      padding: 8px 0;
      mix-blend-mode: difference;
    }
    
    .sidenav a {
      clear: both;
      float: left;
      position: relative;
      left: -20%;
      padding: 10px;
      margin-bottom: 15px;
      transition: 0.3s;
    
      text-decoration: none;
      text-align: right;
      font-size: 24px;
    
      border-style: solid;
      border-width: 2px;
      border-color: #fff;
      border-radius: 0 5px 5px 0;
    
      color: #fff;
      background-color: #000;
    
    }
    
    .sidenav a:hover {
      left: -2px;
    }
    
    .sidenav a.selected {
      left: -2px;
      color: #000;
      background-color: #fff;
      cursor: default;
    }
    <!doctype html>
    <html>
    <head></head>
    
      <body>
    
        <div class="sidenav">
          <a href="#" class="selected">&emsp;&emsp;Section 1</a>
          <a href="#">&emsp;&emsp;Another Section</a>
          <a href="#">&emsp;&emsp;Last One</a>
        </div>
    
        <div class="content" onclick="closeMenu()">
          <div class="section" id="works">
            <p>Some text<p>
          </div>
          <div class="section blk" id="works">
            <p>Some text<p>
          </div>
          <div class="section" id="works">
            <p>Some text<p>
          </div>
          <div class="section blk" id="works">
            <p>Some text<p>
          </div>
          <div class="section" id="works">
            <p>Some text<p>
          </div>
        </div>
      </body>
    </html>

    you need it add mix-blend-mode to parent element like sidenav, than change backround, color and border-color in a