Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

css - change color of the cursor

Tags:

html

css

I am trying to apply style to the cursor. Below is the code

 <span style="cursor:help ; color:red; font-size:40px;">Help</span><br>

When i tried color:red it changed the text 'Help' to red color. How to make the cursor red?

Here is the fiddle - https://jsfiddle.net/user_123/aoubt7yv/

Please help. Thanks in advance.

like image 426
user56690 Avatar asked May 19 '16 15:05

user56690


3 Answers

Cursors aren't really stylable like you might expect at least not using properties that would traditionally target DOM elements.

The best approach would be to set the cursor attribute to a URL that contains your preferred cursor as seen below :

/* This will change your cursor to the image at your URL */
cursor: url('{your-red-cursor-url}'), auto;

Example

enter image description here

.red-cursor {
  color:red; 
  font-size:40px;
  cursor: url('http://www.spacebug.50webs.com/visible.gif'), auto;
}
<div class='red-cursor'>
    Testing
  </div>
like image 79
Rion Williams Avatar answered Oct 19 '22 14:10

Rion Williams


You will probably need to do it as an image as color is for changing the color of text.

You can try an image like this:

.cursor { cursor: url(images/my-cursor-design.png), auto; }

like image 32
Andy Holmes Avatar answered Oct 19 '22 14:10

Andy Holmes


Try replacing the custom cursor image with an image with red background.

 <span style="cursor:url('put-red-image-here'), auto ; font-size:40px;">Help</span><br>

You could use JavaScript, but I believe this is a simpler option.

like image 2
Sarhad Salam Avatar answered Oct 19 '22 15:10

Sarhad Salam