gpt4 book ai didi

javascript - 在已经更改默认光标之后更改指针

转载 作者:行者123 更新时间:2023-11-28 10:03:56 26 4
gpt4 key购买 nike

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

最佳答案

试试这个:

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

Demo

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

关于javascript - 在已经更改默认光标之后更改指针,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24623562/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com