I want to use a custom image for a cursor.
This is fine, but from what I can see - the origin (tip of arrow) is by default at the top-left point of my image.
How can I set the origin to be the center of my image.
Here is a demo snippet to demonstrate the problem
div { width: 600px; height: 100px; background: pink; cursor: url(http://placehold.it/50x30), auto }
<div>the cat in the hat<br> the cat in the hat<br> the cat in the hat<br> the cat in the hat</div>
Notice that when I try to select the text - it selects from the top-left of the image.
You can define a custom position for the cursor hotspot by adding x & y coordinates for where the hotspot should be in the provided custom image.
Customizing cursors is an easy way to add an extra flourish to your site when needed. To specify the cursor appearance, use the CSS cursor property, which is used to change the mouse cursor type on elements.
For specifying the cursor appearance use the CSS cursor property. This property is used to change the mouse cursor type on elements. It can be useful in websites where different actions should be done rather than just clicking.
You can define a custom position for the cursor hotspot by adding x & y coordinates for where the hotspot should be in the provided custom image. Note that, when using svg cursors, it’s important that your svg has width & height values on the root svg element, or else your cursor won’t show.
One solution would be to move the position of your image to match the mouse pointer
cursor: url(image) [x y|auto];
Doesn't respond to the question but this is working
HTML
div { width: 600px; height: 100px; background: pink; cursor: url(http://placehold.it/50x30) 25 15, auto; }
You can set it by:
cursor:url(http://placehold.it/50x30) 25 15, auto;
The two parameters I added set the center of your cursor.
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