2014-07-08 55 views
0

我创建了一个风格化的页面,并且已经更改了默认光标,但是当您将鼠标悬停在链接上时,它会返回到标准“指针”。我想改变标准指针,就像我使用默认光标一样。我尝试了一些我发现的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; 
    } 
+0

你能发布整个img链接吗? – imbondbaby

+0

这是你的意思吗? 'file:/// J:/ Graphic/webfolio/img/cursor.png' –

回答

0

试试这个:

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

Demo

P.S:在演示中使用的随机图像。

+1

我喜欢这个修补程序,因为我试图尽可能多地使用CSS/HTML,并尽量减少Js/Jquery。谢谢! –

+0

它让我等了5分钟出于某种原因,我不知道它是否因为某人基于我的html没有被刷新的事实而投票给我,并且不包括我的''......〜卷眼〜 –