Forum Moderators: not2easy

Message Too Old, No Replies

IE6: Links showing through DIV

On IE6 only, links are showing through a DIV made visible on hover.

         

mattdeclaire

9:25 pm on May 2, 2008 (gmt 0)

10+ Year Member



I am having trouble with an IE6 bug. I have included source below representing the problem boiled down to it's core.

The code's intentions: User hovers over a link and a box appears, hovering above the link, with a short description.

IE6 bug: The box correctly hovers above the intended link, but other links show through the box. Only links with the class applied show through, not "regular" links. I highly suspect that the culprit is the

position: relavite
on
a.hoverLink
, but this rule is required to properly align the box once it becomes visible.

Small note: The

border-color: red
is in there as another IE6 fix. IE6 will not redrawn the hover box on
a:hover
unless a significantly "important" attribute changes.
border-color
fills that role.

I hope you guys can help me out.


<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<style type="text/css">
a.hoverLink {
position: relative;
}

a.hoverLink div {
z-index: 1;
position: absolute;
left: -10000px;
top: 5px;
width: 200px;
border: 2px solid #333;
background-color: #DDD;
color: #333;
text-decoration: none;
}

a.hoverLink:hover div {
left: 10px;
}

a:hover { /* IE Fix */
border-color: red;
}
</style>
</head>

<body>

<div>
<a href="#" class="hoverLink">
Hover Link
<div>
<p>Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Proin imperdiet metus sit amet massa.</p>
</div>
</a>
</div>

<div>
<a href="#" class="hoverLink">
Hover Link
<div>
<p>Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Proin imperdiet metus sit amet massa.</p>
</div>
</a>
</div>

<div>
<a href="#" class="hoverLink">
Hover Link
<div>
<p>Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Proin imperdiet metus sit amet massa.</p>
</div>
</a>
</div>

<a href="#">Regular Link</a>

</body>
</html>

vincevincevince

4:33 am on May 3, 2008 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



z-index:1 is the source of your misery I believe.

a.hoverLink should have z-index:1; whilst the div should have z-index:2 or greater

As for your general approach, I suggest that instead of moving the DIV on and off the screen, you switch the visibility: or the display: for a more consistent response.

mattdeclaire

3:45 pm on May 5, 2008 (gmt 0)

10+ Year Member



z-index
Ah, my mistake. I had previously set the z-index up higher, and forgot to change it back. The issue still exists with a z-index of 2, or 1000, as I had set it. I was testing what happened when set to 1.

display
I am currently moving the div off-screen as a work-around for the case where the "pop-in" would normally fall off the bottom. When

left: -10000px
, the window provides vertical scroll space for the div. In my final code, I've also got a special case for those "pop-ins" that fall off the right side of the screen.