Forum Moderators: not2easy

Message Too Old, No Replies

IE7 :hover only works on hover over content?

         

heisters

6:38 pm on Jul 17, 2007 (gmt 0)

10+ Year Member



Hi all,

I have some elements (li) that have :hover applied to show the background of a child, the effect being that the li is highlighted on mouseover:

.search_results .listing .orange {
background: none;
}
.search_results .listing .orange>.left,
.search_results .listing .orange>.right,
.search_results .listing .buttons {
visibility: hidden;
}
.search_results .listing:hover {
background-color: white;
}
.search_results .listing:hover .rounded-left.orange {
background: transparent url(/images/orange/left.png) repeat-y 0 0;
}
.search_results .listing:hover .rounded-right.orange {
background: transparent url(/images/orange/right.png) repeat-y top right;
}
.search_results .listing:hover .rounded-top.orange {
background: transparent url(/images/orange/top.png) repeat-x 0 0;
}
.search_results .listing:hover .rounded-bottom.orange {
background: transparent url(/images/orange/bottom.png) repeat-x bottom center;
}
.search_results .listing:hover .orange>.left,
.search_results .listing:hover .orange>.right,
.search_results .listing:hover .buttons {
visibility: visible;
}

I also know that IE7 needs a strict doctype to kick in standards mode, and as such I'm using:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">

And it works! Well, sort of. It works in FF and Opera. In IE7 it works correctly only so long as the cursor is over actual content in the li. So if the mouse is over text, the background shows up, but as soon as the mouse moves to a blank part of the li, the background disappears.

Any ideas?

Let me know if you want me to whip up a minimalized example; I thought someone might know what's going on without the need for that.

Thanks!

P.S. I know "orange" isn't a semantic class name, but it makes sense in the context of the API.

Robin_reala

7:11 pm on Jul 17, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Although I thought IE7 had fixed this problem, you might try triggering hasLayout on the affected elements (my weapon of choice is zoom:1;). IE6 certainly sometimes needs this - the most obvious situation is when you make an <a> display:block.

[edited by: Robin_reala at 7:12 pm (utc) on July 17, 2007]

heisters

12:10 am on Jul 18, 2007 (gmt 0)

10+ Year Member



Yes! I actually went off to fix another bug and used your "zoom:1" on that (much nicer than the height:1 I used to use with IE6), and it fixed this too.

Thanks.