简体   繁体   English

Cursor 代码,不显示自定义 cursor 集。 CSS

[英]Cursor code, not showing the custom cursor set. CSS

pretty new to CSS and HTML and was hoping somebody could help me fix this. CSS 和 HTML 还很新,希望有人能帮我解决这个问题。 I wanted to be able to change the icon for the cursor although when I run the code, simply no change.我希望能够更改 cursor 的图标,尽管当我运行代码时,根本没有任何变化。 A few visits to chatGPT hasnt done me much either.几次访问 chatGPT 对我也没有太大帮助。 Here's my code:这是我的代码:

body2 {
  cursor: url("assets/img/wiiu/Smile_icon_32x32.png"), url("assets/img/wiiu/cursor.svg"), auto;
}

And yes, it is 32x32.是的,它是 32x32。

I've tried moving it to different classes, changing words, changing everything.我试过把它移到不同的班级,改变措辞,改变一切。 Although nothing has worked.尽管没有任何效果。

here is a good reference: https://developer.mozilla.org/en-US/docs/Web/CSS/cursor?retiredLocale=de这是一个很好的参考: https://developer.mozilla.org/en-US/docs/Web/CSS/cursor?retiredLocale=de

So basically you try to applie to a body2 HTML element you're CSS code.所以基本上你尝试应用到body2 HTML 元素你是 CSS 代码。 If its a class try the CSS selector .body2 {} or in the case its an id of a HTML element #body2 {} .如果它是 class 尝试 CSS 选择器.body2 {}或者在这种情况下它的 id 是 HTML 元素#body2 {}

In you're css you've got one main picture and the second one as fallback.在你的 css 中,你有一张主图片,第二张作为备用图片。 Just make sure you set the correct path corresponding to the location of you're CSS file.只需确保设置与 CSS 文件位置对应的正确路径即可。 To ensure that, you can also try the full path instead of the relativ one like C:\Users\xxx\Smile_icon_32x32.png为确保这一点,您还可以尝试使用完整路径而不是相对路径,例如C:\Users\xxx\Smile_icon_32x32.png

You are using the wrong css declaration, your code will only work if you have defined a custom html element having <body2> as tag.您使用了错误的 css 声明,只有当您定义了一个自定义的 html 元素时,您的代码才会工作<body2>作为标签。

What you probably want is:你可能想要的是:

body {... }身体 {... }
applied to <body> tag应用于<body>标签

or a css class或 css class

.body {... } applied to or any other tag having body as class. .body {...} 应用于或任何其他具有body作为 class 的标签。

or a css id或 css id

#body {... } applied to or any other kind of tag with body as id. #body {... } 应用于或以body作为 id 的任何其他类型的标签。

Alternatively check in the browser console if the rule is applied and if the image path is resolved correctly.或者检查浏览器控制台是否应用了规则以及图像路径是否正确解析。

Here is an example where http://example.com/32x32/990000/fff.png&text=PNG don't exist and https://dummyimage.com/32x32/009900/fff.gif&text=GIF exist so the gif will be used instead of the png:这是一个示例,其中http://example.com/32x32/990000/fff.png&text=PNG不存在并且https://dummyimage.com/32x32/009900/fff.gif&text=GIF存在,因此 gif 将是使用而不是 png:

 .body2 { display:inline-block; cursor: url("http://example.com/32x32/990000/fff.png&text=PNG"),url("https://dummyimage.com/32x32/009900/fff.gif&text=GIF"), auto; }
 <div class="body2">display</div>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM