Is it possible to use external image URLs for CSS custom cursors? The following example doesn't work:
HTML:
<div class="test">TEST</div>
CSS:
.test { background:gray; width:200px; height:200px; cursor:url('http://upload.wikimedia.org/wikipedia/commons/d/de/POL_apple.jpg'); }
Fiddle: http://jsfiddle.net/wNKcU/4/
Answer: Use the CSS cursor propertygif or . png (for Firefox, Chrome, Safari) and . cur for (for Internet Explorer). After that apply the cursor property with a comma-separated list of URLs pointing to these cursor images.
To change the default mouse cursor using an external image, you need to: Create an SVG image; Convert it to data URI so that you can use it in CSS.
Now how do I use CSS to customize a mouse cursor? To use this, you just have to tell CSS what image you intend to use and point the cursor property to the image URL using the url value. From the code snippet above, you can see I set this on the document body, so it can apply to the cursor no matter where it moves.
It wasn't working because your image was too big - there are restrictions on the image dimensions. In Firefox, for example, the size limit is 128x128px. See this page for more details.
Additionally, you also have to add in auto
.
jsFiddle demo here - note that's an actual image, and not a default cursor.
.test { background:gray; width:200px; height:200px; cursor:url(http://www.javascriptkit.com/dhtmltutors/cursor-hand.gif), auto; }
<div class="test">TEST</div>
I would put this as a comment, but I don't have the rep for it. What Josh Crozier answered is correct, but for IE .cur and .ani are the only supported formats for this. So you should probably have a fallback just in case:
.test { cursor:url("http://www.javascriptkit.com/dhtmltutors/cursor-hand.gif"), url(foo.cur), auto; }
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With