Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>After creating a CSS class, say <code>.fade</code> (with CSS code for transitions etc.), go along this way </p> <pre><code>.hidden { display: none; } </code></pre> <pre><code>&lt;div class="main"&gt;I'll host the hovering div&lt;/div&gt; &lt;div class="hidden fade"&gt;Overlay content&lt;/div&gt; </code></pre> <p>JavaScript Code - </p> <pre><code>var mainDiv = document.querySelector('div.main'); var hoverDiv = document.querySelector('div.hidden'); mainDiv.addEventListener('mouseover', function() { hoverDiv.classList.toggle('hidden'); var h = function() { this.classList.toggle('hidden'); this.removeEventListener('mouseout',h,false); } hoverDiv.addEventListener('mouseout',h,false); },false); </code></pre> <hr> <p>Edit</p> <hr> <p><a href="http://jsfiddle.net/XDgmD/2/" rel="nofollow">http://jsfiddle.net/XDgmD/2/</a></p> <pre><code>body { background-color: silver; } .main { position: absolute; top: 0; left: 0; width: 100px; height: 100px; background-color: blue; box-shadow: 0px 0px 10px yellow; } .hidden { display: none; } .fade { position: absolute; top: 0; left: 0; width: 100px; height: 100px; background-color: black; z-index: 10; color: white; } </code></pre> <hr> <pre><code>var mainDiv = document.querySelector('div.main'); var hoverDiv = document.querySelector('div.hidden'); mainDiv.addEventListener('mouseover', function() { hoverDiv.classList.toggle('hidden'); var h = function() { this.classList.toggle('hidden'); this.removeEventListener('mouseout',h,false); } hoverDiv.addEventListener('mouseout',h,false); },false); </code></pre> <hr> <pre><code>&lt;div class="main"&gt;I'll host the hovering div&lt;/div&gt; &lt;div class="hidden fade"&gt;Overlay content&lt;/div&gt; </code></pre>
 

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