Hello,
As you guys know, the CSS :hover
doesn't work in d.... IE6 for an element except for links. What is the fix for that. I mean how do I apply the :hover
to a div
for example.
Any fix/alternative/solution?
Thanks.
Hello,
As you guys know, the CSS :hover
doesn't work in d.... IE6 for an element except for links. What is the fix for that. I mean how do I apply the :hover
to a div
for example.
Any fix/alternative/solution?
Thanks.
There's whatever:hover. I've never used it myself but from what I hear, it works well.
Whatever:hover is a small script that automatically patches :hover, :active and :focus for IE6, IE7 and IE8 quirks, letting you use them like you would in any other browser. Version 3 introduces ajax support, meaning that any html that gets inserted into the document via javascript will also trigger :hover, :active and :focus styles in IE.
You can use the famous IE7.js from Dean Edwards, which has the nice advantage, that you can use the :hover
selector in your CSS.
Apart from that, I doubt that you can achieve it with CSS alone. IE can handle JS in CSS files via expression()
, but you can't get to an expression to handle hovering without a selector handling hovering, if you catch my drift.
Then, finally, a short jQuery solution:
$(document).ready(function () {
$('div').hover(function () {
$(this).addClass('hover');
}, function () {
$(this).removeClass('hover');
});
});
Then you can use this in your stylesheet:
div:hover, div.hover { ... }
Suckerfish vs. .htc
IIIIN the blue corner we have Suckerfish, the original lightweight, accessible, cross-browser, standards-compliant :hover mimic. IIIIN the red corner we have '.htc' - the JavaScript files accessed via CSS to mimic :hover.
Ding ding!
And Suckerfish instantly lands a heavy blow on .htc's validity - .htc simply isn't standards compliant CSS.
Oooo... .htc sneaks in a crafty jab without the need for additional selectors...
Suckerfish bounces around the ring. He's much lighter weight than his opponent.
And OH! The IE 5.0 uppercut! That's something that .htc just doesn't have the skill to do, whereas Suckerfish can work IE 5.0 seamlessly.
.htc is dazed! And the contest is over! Suckerfish wins on points! TKO!
IE7.js
as @Boldewyn suggestedNO pure and valid CSS solution available for this in IE6.
One Non- valid CSS expression solution is available but i would not not advise to use this because it's slow
Solution: http://www.visibilityinherit.com/code/ie6-hover-expression.php
suckerfish and it's offspring provde great lightweight alternatives for this purpose too.