css - webkit-filter changing z-index stacking order -


why applying webkit filter changes layers order?

see minimal example:

setinterval(function(){    	t.classlist.toggle('grayed');        }, 1000)
.floater {      position: fixed;      top: 5vh;      left: 5vw;      width: 90vw;      height: 90vh;      z-index: 99;      background: yellow;      display: none;  }  td:hover .floater{      display: initial;  }    .grayed td{      -webkit-filter: grayscale(0.5);  }    td{      padding: 1em;      text-align: center;      background: blue;  }
<table id="t">      <tr>          <td>1</td>          <td>2</td>          <td>3</td>      </tr>      <tr>          <td>4</td>          <td>5<br>              (mouse on this)              <div class="floater">hello</div>          </td>          <td>6</td>      </tr>      <tr>          <td>7</td>          <td>8</td>          <td>9</td>      </tr>  </table>

  • child's z-index set same stacking index parent, hence why it's not working.
  • if willing take floater out of it's table parent, try below js approach mouseover & mouseout (to close).

setinterval(function() {    t.classlist.toggle('grayed');    document.queryselector('.floater').classlist.toggle('grayed');  }, 1000)    document.queryselector('.tohover').addeventlistener('mouseover', function() {    document.queryselector('.floater').classlist.add('open');  })  document.queryselector('.floater').addeventlistener('mouseout', function() {    document.queryselector('.floater').classlist.remove('open');  })
.floater {    position: fixed;    top: 5vh;    left: 5vw;    width: 90vw;    height: 90vh;    z-index: 1;    background: yellow;    display: none;  }    .grayed td {    -webkit-filter: grayscale(0.5);  }    .grayed {    -webkit-filter: grayscale(0.5);  }    .open {    display: initial;  }    td {    padding: 1em;    text-align: center;    background: blue;  }
<table id="t">    <tr>      <td>1</td>      <td>2</td>      <td>3</td>    </tr>    <tr>      <td>4</td>      <td class="tohover">5<br> (mouse on this)        <div>hello</div>      </td>      <td>6</td>    </tr>    <tr>      <td>7</td>      <td>8</td>      <td>9</td>    </tr>  </table>    <div class="floater">hello</div>


Comments

Popular posts from this blog

Is there a better way to structure post methods in Class Based Views -

performance - Why is XCHG reg, reg a 3 micro-op instruction on modern Intel architectures? -

jquery - Responsive Navbar with Sub Navbar -