YonahW
YonahW

Reputation: 16560

IE 6 CSS Hover non Anchor Tag

What is the simplest and most elegant way to simulate the hover pseudo-class for non-Anchor tags in IE6?

I am specifically trying to change the cursor in this instance to that of a pointer.

Upvotes: 8

Views: 6774

Answers (8)

Jon Galloway
Jon Galloway

Reputation: 53155

I think the simplest way is to use the hover.htc approach. You add the hover.htc file to your site, then reference it in your stylesheet:

body { behavior:url("csshover.htc"); }

If you want to keep things as clean as possible, you can use IE conditional comments so that line is only rendered users with IE6.

Upvotes: 12

Sören Kuklau
Sören Kuklau

Reputation: 19970

Another alternative that will fix many more issues in one go is to use IE7.js.

Upvotes: 3

GateKiller
GateKiller

Reputation: 75967

If your willing to use JQuery, I would use Set Hover Class for Anything technique.

Upvotes: 0

YonahW
YonahW

Reputation: 16560

I liked the mouseover/out best since I actually already needed to swap the image anyhow. I really should have thought of doing this with javascript to begin with.

Thanks for the quick answers.

@Joseph

Thanks for that link. I had never heard of this technique before and really like the idea.

I will definitely try that out and see how I fare with it.

Upvotes: 0

Nathan Peretic
Nathan Peretic

Reputation: 463

Regarding your request -- I am specifically trying to change the cursor in this instance to that of a pointer -- the easiest way is to specify cursor:pointer in your css. I think you will find that works in IE 6.

Try this to verify (where div can be any element):

<div style="background:orange; cursor:pointer; height:100px; width:100px;">
    Hover
</div>

Upvotes: 6

Joseph Pecoraro
Joseph Pecoraro

Reputation: 2876

Aside:

I actually already needed to swap the image anyhow

Make sure you take a look at Image Sprites. Sometimes its much nicer to use one image and "shift" the image then to use two separate images and "toggle" or "swap" between them. In my experience its been much nice when as user interacts with it is sometimes an advantage that there is a single request for the 1 image then multiple requests for multiple images.

Upvotes: 1

Benjamin Autin
Benjamin Autin

Reputation: 4171

I would say that the simplest method would be to add onmouseover/out Javascript functions.

Upvotes: 4

Haacked
Haacked

Reputation: 59061

Another approach, depending on what the item is, is to add a non link anchor and set its display to block. Either put the anchor within or surrounding the item you want the pseudo hover behavior on.

Upvotes: 1

Related Questions