Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>A <code>z-index</code> is relative to the the stacking context, not relative to the document. If you want the <code>expose</code> element to appear over the overlay, they must either be siblings, or you must explicitly position <code>.expose</code> using <code>position:*</code>.</p> <p>In general, the elements must be part of the same stacking context in order for their z-index values to be compared. You can learn more about stacking contexts <a href="https://developer.mozilla.org/en-US/docs/CSS/Understanding_z-index/The_stacking_context" rel="nofollow">here</a>.</p> <p>Some additional points:</p> <ol> <li>You should make the overlay transparent to pointer events. You can do this by using <code>pointer-events:none;</code></li> <li>You do not need to bind to <code>.expose</code> when the container is moused over. Bind the handlers in parallel with the handler for showing/hiding the overlay</li> </ol> <p>Here is the corrected code. You can see a working demonstration <a href="http://jsfiddle.net/sMw5D/" rel="nofollow">here</a>:</p> <p><strong>CSS:</strong></p> <pre><code>#overlay { background:rgba(0,0,0,0.3); display:none; width:100%; height:100%; position:absolute; top:0; left:0; z-index:99998; pointer-events:none } .expose{ background-color:red; position:relative; } </code></pre> <p><strong>JS:</strong></p> <pre><code>$('.entry-content').hover(function() { $('#overlay').fadeIn(300); }, function() { $('#overlay').fadeOut(300); }); $('.expose').hover(function(e) { $(this).css('z-index', '99999'); },function(e) { $(this).css('z-index', '1'); }); </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload