Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is it possible to ignore mix-blend-mode of the element?

Tags:

javascript

css

I have a component which has a "sticky" header at the top and list of elements that use blending modes. In this simplified example, it's headers inside divs.

It works fine until I scroll content. If I scroll down, blending mode also applies to blend "sticky" header with elements which is not what I want.

Is there any way to make a "sticky" header to ignore the blending modes of an another element and always just cover the elements behind.

enter image description here enter image description here

See code below.

<div>
    <div style="display: flex; flex-direction: column; height: 700px; max-height: 700px; overflow: auto; text-align: center;">
        <div style="position: sticky; top: 0px; background: blue;">Sticky</div>
        <div style="background: lightblue;">
            <h1 style="background: red; mix-blend-mode: multiply;">ABC</h1>
        </div>
        <div style="background: lightblue;">
            <h1 style="background: red; mix-blend-mode: multiply;">ABC</h1>
        </div>
        /* a lot of other elements like 2 above*/
    </div>
</div>
like image 239
Valerii Avatar asked Oct 23 '25 12:10

Valerii


1 Answers

you just have to add z-index: 1000; on Sticky style

.class_Parent {
  display: flex;
  flex-direction: column;
  height: 700px;
  max-height: 700px;
  overflow: auto;
  text-align: center;
}
.class_Sticky {
  position: sticky;
  top: 0px;
  background-color: blue;
  z-index: 1000;
}
.class_ABC {
  background: lightblue;
}
.class_ABC h1 {
  background: red;
  mix-blend-mode: multiply;
}
<div>
  <div class="class_Parent">
    <div class="class_Sticky">Sticky</div>

    <div class="class_ABC"> <h1>ABC</h1> </div>
    <div class="class_ABC"> <h1>ABC</h1> </div>
    <div class="class_ABC"> <h1>ABC</h1> </div>
    <div class="class_ABC"> <h1>ABC</h1> </div>
    <div class="class_ABC"> <h1>ABC</h1> </div>
    <div class="class_ABC"> <h1>ABC</h1> </div>
    <div class="class_ABC"> <h1>ABC</h1> </div>
    <div class="class_ABC"> <h1>ABC</h1> </div>
    <div class="class_ABC"> <h1>ABC</h1> </div>
    <div class="class_ABC"> <h1>ABC</h1> </div>
    <div class="class_ABC"> <h1>ABC</h1> </div>
    <div class="class_ABC"> <h1>ABC</h1> </div>
    <div class="class_ABC"> <h1>ABC</h1> </div>
    <div class="class_ABC"> <h1>ABC</h1> </div>

  </div>
</div>
like image 116
Mister Jojo Avatar answered Oct 25 '25 01:10

Mister Jojo