PDA

View Full Version : Custom Cursor on mouseover possible?



Soots
04-14-2005, 11:20 PM
Is it possible?

style="cursor:url("mycursor.cur");"

I wanted to have that in a link, for example:
<A HREF="URL" style="cursor:url("mycursor.cur");"></A>
As far as I know, that syntax will not work, but if anyone can tell me a way to have a cutom Cursor on mouseover, let me know.

mwinter
04-14-2005, 11:31 PM
Is it possible?Yes[1], but only via a proper style sheet, and then only on a elements[2].


<head>
<!-- ... -->

<style type="text/css">
selector:hover {
cursor: url(...), fallback;
}
</style>
</head>What you'll use in place of selector and fallback will vary based on what you're trying to style, and where. The fallback value will probably be default but I couldn't guess at selector without seeing at least a sample of your mark-up in context.

Mike


[1] At least in IE. I can't recall any other user agents supporting custom cursors.
[2] You can apply the :hover pseudo-class to any element, but IE only supports it with a elements, unlike most user agents.

jscheuer1
04-15-2005, 04:20 AM
<A HREF="URL" style="cursor:url("mycursor.cur");"></A>Actually this would work but, you've used incorrect quoting. Use:
<A HREF="URL" style="cursor:url('mycursor.cur');"></A>It will be fine in IE6 and Modern Mozilla, however only IE6 will display it. Some browsers may get confused by it however, and act unpredictably.

Soots
04-15-2005, 11:25 AM
It works now thanks, you guys are awsome. :)

mwinter
04-15-2005, 06:17 PM
I cite tiredness for the travesty that was my previous post.

The use of the :hover pseudo-class isn't necessary, however it would be better to use a style sheet rule, rather than inline style attributes if the custom cursor is to be applied to more than one element.

The fallback value that I was thinking of was auto not default. Please note that a standard cursor type is mandatory. Even if IE accepts the declaration now, it might not in the future as Microsoft are making some moves towards better conformance.

As for the quotes within the attribute, the easier alternative is omit them altogether.

Mike