IE7 hover over a div when you touch the child of that div

In theory

I have a div (container) that appears when dropped over one of its child divs (dropdown). The dropdown contains images of links, etc., and when I leave it and the container, the dropdown disappears.

<div id="container">
  <div>Hover over me to see extra stuff</div>
  <div id="drop-down">
     <div>
       <img />
     </div>
     <div>
       <a />
       <p><span>Info</span><span>More</span></p>
     </div>
     <img />
  </div>
</div> 

      

This is what jQuery looks like

$('#container').hover(
  function(){ $(this).find('#drop-down').addClass('hover'); },
  function(){ $(this).find('#drop-down').removeClass('hover'); }
);

      

Here is the CSS for the hover

#container #drop-down {left: -9999px;}
#container .hover {left: 0;}

      

On practice

In every browser other than IE7, it works fine, but when I highlight the spaces in the first containing div in the dropdown, then the drop-down disappears for some reason, as if I left the container.

Question

I have been banging my head against the wall for almost 3 hours now trying to find all the errors I could check if they were appropriate, but unfortunately no luck. I originally thought it might be a "z-index" problem, but since it actually appears above the content below, it can't be (and I tried it by setting "position: relative; z-index: 9999;" ; both on p and on spans). Other than that, I'm completely stumped. However, I know that any elements below that div (like the image tag in the above example) create a problem after traversing around the spans at the p's position.

Further clarification: I found it to do the elements underneath the spans, but since they don't show, I have no idea how to fix this. Also, it doesn't matter what element is under it, only if there is a div underneath that you can "enter" (ie you are not in it yet), then you lose hover and the dropdown disappears.

I know I have not supplied the CSS, but can anyone think of any reason why this might be happening? Also, I disabled all CSS working directly on it and this is still affected, but this is the problem.

+2


source to share


3 answers


As said in the comments

Placing a background color in the gap will cause it to hang. For some reason, when you hover over a transparent background in IE, it thinks the mouse should no longer be in the dom (or in this case, the span), but instead on the element below it, and raises the mouse event.



Microsoft is looking into this bug and is referencing this msdn entry

+6


source


Found out what makes items disappear in older version of IE. Copy add this to your css

div { display: inline-block; }

div { display: block; }

      



This explains the error.

+2


source


div { display: inline-block; }  div { display: block; } 

      

It worked for me ... wow what a pain.

+1


source







All Articles