2014-07-08 95 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沒有被刷新的事實而投票給我,並且不包括我的''......〜卷眼〜 –