Trying to implement a personalized cursor with CSS was unsuccessful

I implemented a custom cursor for my website using an .ico file, but unfortunately it's not displaying correctly.

Here's the CSS I used:

html, body {
    cursor: url("images/39020_fPv_icon.ico"), url("images/39020.png"), default;
  }

If anyone has any insights on why it's not working, I would greatly appreciate it. Thank you!

Answer №1

There may be a problem with the URL. To test this, try using crosshair instead of default and check if the cursor changes. Also, note that the style might be cached in the browser, so pressing Ctrl+F5 on most browsers should reload the page without cache.

html, body {
    cursor: url("images/39020_fPv_icon.ico"), url("images/39020.png"), crosshair;
}

If changing the cursor to a crosshair resolves the issue, then the problem lies with your URLs. You can either troubleshoot the URLs or base64 encode the cursor images for two advantages:

  1. You won't have to worry about moving files or maintaining links.
  2. If you deploy to a new environment, you won't need to concern yourself with the cursor image locations.

However, encoding the images may increase the size of your CSS file. Since cursor images are typically small, this shouldn't be much of an issue.

To base64 encode an image, search "base64 encode image" online - a top result is base64-image.de, a site I have used before. Your CSS would then resemble something like this:

html, body {
    cursor: url("data:image/gif;base64,R0lGODdhBQAFAPABAP////8AACwAAAAABQAFAAACCARihhe9q0wBADs=="), crosshair;
  }

If changing from default to crosshair still doesn't yield any results, there are two possibilities:

  1. If you haven't provided any HTML code, it's possible that your browser isn't rendering anything. The HTML and body will only occupy space based on their content, so lack of content equals zero-sized HTML and body elements.
    html {
        height: 100%;
        width: 100%;
    }
  1. If there is content on the HTML but the cursor remains unchanged, it's possible that the cursor isn't being applied to all elements on the page. You can modify your cursor-related CSS to apply it to all elements within the body like this:
    html, body, body * {
        cursor: url("images/39020_fPv_icon.ico"), url("images/39020.png"), default;
    }

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Transform collapsible color upon materialize click

Is there a way to change the color of the collapsible header only when clicked? I'm struggling with adding the color inside the class element while calling the "connect" function. Can this be achieved? <div class="collapsible-header" onclick="conn ...

Learn how to display my API items in rows of 5 using the Vue framework

Currently, I am utilizing Vue for the front-end development and I am looking to dynamically display 5 items on each row. I want it to appear like this: 1 1 1 1 1 1 1 1 1 1 However, when I iterate through the array items, each item is displayed in a row. ...

Utilizing Vue's v-for directive to manipulate data through custom looping

When I loop through my data using v-for, I find myself unsure of how to display the data with a custom looping method, such as using modulus. I aim to display the data in groups of three items, assigning a different class to every 3 items. The desired st ...

Using Jquery to Highlight the Background Image in a Circle

I currently have 3 images named back_about_1.jpg, back_about_2.jpg, and back_about_3.jpg. There is a div with the ID "about" - <div id="about"></div> The default background image of the div is set to back_about_1.jpg using CSS - background: u ...

How do I make an image fill the entire space of a div using JQuery and CSS?

html: <body> <div class="custom-div"><input type="button" id="x" name="button" value="Search" onclick="showUser()" class="button"/></div> <input type="image" name="button" value="Search" onclick="showUser()" class="bu ...

What are the drawbacks of utilizing CSS word-wrap across all elements on a website?

Is there a downside to utilizing the CSS property word-wrap:break-word in this manner? body { word-wrap: break-word; } The definitions for the values of this property are as follows: normal: Breaks words only at allowed breakpoints break-word: Perm ...

What is the best way to deactivate a button when a certain input field is left blank?

I'm having trouble figuring out how to deactivate a button when specific input fields are empty, while others can remain optional for the process. In my course, we were taught to disable the button until all inputs are valid, so I'm a bit confus ...

Ways to conceal or deactivate button controls on videojs?

I am building an application using video.js and Vue. I am looking for a way to hide or disable certain controls like the play button, playback rate, and make the progress bar read-only. In the video.js documentation, I found that using controls: false hi ...

How can I modify the value of a CSS animation rule in AngularJS?

I am looking to dynamically change the value assigned to stroke-dashoffset based on a custom input. @-webkit-keyframes donut-chart-1 { to { stroke-dashoffset: 100; } } @keyframes donut-chart-1 { to { stroke-d ...

Activate the mouseenter event as soon as an animated element makes contact with the cursor

As I venture into the world of web development, I am currently working on creating a game where the main objective is to avoid touching moving circles with the cursor. My approach involved using a mouseenter event as shown in the JSFiddle example below: $ ...

When I use `console.log` with `req.body` in Node, the password is

Currently, I am utilizing NodeJs on the backend to console.log(req.body) data from a form that gathers usernames and passwords from users. I have noticed that this method exposes the collected username and password information. Should I be concerned abou ...

Increasing and preserving the width value of a div using SCSS?

I am currently working on a div where I need to increase the width based on checkboxes that are selected. The goal is to add to the width as more checkboxes get checked. Here is an example of the HTML code I'm working with (please excuse any syntax e ...

When state updates in React, the component will rerender without affecting its style

There seems to be a minor oversight on my part. The issue arises in the parent component where I maintain a state of selected items, which are added from the child component. The background color of the child component changes when an item is selected. Ad ...

Is using a div inside a li considered incorrect?

For instance; <ul> <li> <div class="img1"><img src="img.jpg" /></div> <div class="cs1">Some text</div> <div class="cs2">other text</div> <div class="button">Click here</div> ...

Implementing AngularJS with the use of the "bind(this)"

Lately, I have made the switch to using "this" in the controllers and controllerAs in ngRoute and Directives instead of accessing $scope directly. While I do appreciate the aesthetic appeal of the code, I find myself needing to manually bind "this" to each ...

Ways to extract information from a table cell located next to a table cell with colspan

As a beginner in web scraping, I am gradually making progress. However, I'm facing a tough challenge with this particular task. My goal is to extract data from the ESPN NBA boxscore website: I aim to scrape the names of players labeled as "DNP" (Did ...

Generating containers in Angular using *ngFor

As a beginner in Angular, Bootstrap, and front-end programming, I am looking to create multiple boxes that reveal detailed information when clicked. This is the desired outcome: https://i.sstatic.net/Ak0eA.png After clicking on box number 1: https://i.s ...

Get the child element from a list within an element using XPath on Sales Navigator

I am attempting to extract the names and positions of random individuals from Sales Navigator. Each person is displayed as a card containing all their information. Despite obtaining a list of these cards, I am struggling to retrieve the Name and Title for ...

Using JQUERY to select all child checkboxes within a tree structure and check them all

I am looking to create functionality where checking the parent checkbox will automatically check all child checkboxes. While I have gotten this to work for the bottom parent checkbox, it does not seem to function correctly for any parent checkboxes highe ...

Ways to choose the correct css styling

I'm currently working on creating navigation using Bootstrap 4, but I've hit a roadblock in adjusting the li items to suit my navigation needs. I'm struggling to figure out how to select these li tags since they are nested in multiple classe ...