【问题标题】:Changing Pointer, after already changing default cursor在已经更改默认光标之后更改指针
【发布时间】:2014-07-08 04:10:08
【问题描述】:

我正在创建一个风格化的页面,并且已经更改了默认光标,但是当您将鼠标悬停在链接上时,它会回到标准的“指针”。我想像使用默认光标一样更改标准指针。我尝试了一些我发现的 javascript,但它似乎不起作用。

    <!DOCTYPE html>
<html>
<head>
    <link rel="stylesheet" type="text/css" href="../css/basic.css">
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />

<script>
    var elms = document.getElementsByTagName("*");
    var n = elms.length;
    for(var i = 0; i < n; i ++) {
        if(window.getComputedStyle(elms[i]).cursor == "pointer") {
            elms[i].style.cursor = "url(../img/cursor.png)";
        }
     }
</script>

</head>
<body>
      <a>
      <a>
</body>  
</html>

这是 CSS 光标

    html{
    min-width: 100%;
    min-height:100%;
    cursor: url(../img/cursor.png),auto;
}
body{
    background-color: black;
    cursor: url(../img/cursor.png),auto;
  }

【问题讨论】:

  • 你能发布整个img链接吗?
  • 这是你的意思吗? file:///J:/Graphic/webfolio/img/cursor.png

标签: javascript html css


【解决方案1】:

试试这个:

a:hover, a:active, a:visited {
    cursor: url(../img/cursor.png), auto;
}

Demo

P.S:在演示中使用了随机图片。

【讨论】:

  • 我喜欢这个修复,因为我尝试尽可能多地使用 CSS/HTML,并尽量减少 Js/Jquery。谢谢!
  • 出于某种原因,它让我等了 5 分钟,我不知道是不是因为有人根据我的 html 没有刷新的事实对我投了反对票,并且没有包括我的 &lt;/a&gt; ... ~翻白眼~
猜你喜欢
  • 2020-11-11
  • 2012-02-07
  • 2023-01-14
  • 1970-01-01
  • 2020-07-16
  • 1970-01-01
  • 2020-10-16
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多