平常,我们在浏览界面时,会发现鼠标的样式有所不同,鼠标的样式变化和cursor属性有关。cursor属性的几个关键字:default、pointer、wait、help、text、crosshair。
default:默认光标;
pointer:超链接的指针;
wait:表示程序正在忙;
help:指示可用帮助;
text:指示文本;
crosshair:鼠标呈现十字状;
<span style="cursor: default;">默认光标</span>
<span style="cursor: pointer;">超链接的指针小手</span>
<span style="cursor: wait;">指程序正在忙沙漏</span>
<span style="cursor: help;">指示可用的帮助</span>
<span style="cursor: text;">指示文本</span>
<span style="cursor: crosshair;">十字状</span>
更改样式图标很简单,只需要在鼠标的指针样式前面添加一个url链接一张鼠标的图片。
这些就是一些鼠标样式图,这些资源文末会给出下载。其他
具体可以自行百度下载。
代码案例
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Documenttitle>
<style>
/** 普通指针样式**/
body {
width: 100vw;
height: 100vh;
cursor: url(./鼠标样式包/arr46.png), auto;
}
/** 链接指针样式**/
a:hover {
cursor: url(./鼠标样式包/arr43.png), pointer;
}
style>
head>
<body>
<a href="#">请点击a>
body>
html>
效果可以看这里:点击这里
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Documenttitle>
<style>
/** 普通指针样式**/
body {
width: 100vw;
height: 100vh;
cursor: url('../../鼠标样式包/arr46.png'), auto;
}
/** 链接指针样式**/
a:hover {
cursor: url('../../鼠标样式包/arr1.png'), pointer;
}
style>
head>
<body>
<canvas class="fireworks" style="position:fixed;left:0;top:0;z-index:99999999;pointer-events:none;">canvas>
<script type="text/javascript" src="djtx.js">script>
body>
html>
代码如下
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Documenttitle>
head>
<body>
<script type="text/javascript">
! function (e, t, a) {
function r() {
for (var e = 0; e < s.length; e++) s[e].alpha <= 0 ? (t.body.removeChild(s[e].el), s.splice(e, 1)) : (s[
e].y--, s[e].scale += .004, s[e].alpha -= .013, s[e].el.style.cssText = "left:" + s[e].x +
"px;top:" + s[e].y + "px;opacity:" + s[e].alpha + ";transform:scale(" + s[e].scale + "," + s[e]
.scale + ") rotate(45deg);background:" + s[e].color + ";z-index:99999");
requestAnimationFrame(r)
}
function n() {
var t = "function" == typeof e.onclick && e.onclick;
e.onclick = function (e) {
t && t(), o(e)
}
}
function o(e) {
var a = t.createElement("div");
a.className = "heart", s.push({
el: a,
x: e.clientX - 5,
y: e.clientY - 5,
scale: 1,
alpha: 1,
color: c()
}), t.body.appendChild(a)
}
function i(e) {
var a = t.createElement("style");
a.type = "text/css";
try {
a.appendChild(t.createTextNode(e))
} catch (t) {
a.styleSheet.cssText = e
}
t.getElementsByTagName("head")[0].appendChild(a)
}
function c() {
return "rgb(" + ~~(255 * Math.random()) + "," + ~~(255 * Math.random()) + "," + ~~(255 * Math
.random()) + ")"
}
var s = [];
e.requestAnimationFrame = e.requestAnimationFrame || e.webkitRequestAnimationFrame || e
.mozRequestAnimationFrame || e.oRequestAnimationFrame || e.msRequestAnimationFrame || function (e) { setTimeout(e, 1e3 / 60)
}, i(
".heart{width: 10px;height: 10px;position: fixed;background: #f00;transform: rotate(45deg);-webkit-transform: rotate(45deg);-moz-transform: rotate(45deg);}.heart:after,.heart:before{content: '';width: inherit;height: inherit;background: inherit;border-radius: 50%;-webkit-border-radius: 50%;-moz-border-radius: 50%;position: fixed;}.heart:after{top: -5px;}.heart:before{left: -5px;}"
), n(), r()
}(window, document);
script>
body>
html>
代码如下
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Documenttitle>
head>
<body>
<script>
(function () {
var a_idx = 0;
window.onclick = function (event) {
var a = new Array("❤富强❤", "❤民主❤", "❤文明❤", "❤和谐❤", "❤自由❤", "❤平等❤", "❤公正❤", "❤法治❤", "❤爱国❤",
"❤敬业❤", "❤诚信❤", "❤友善❤");
var heart = document.createElement("b"); //创建b元素
heart.onselectstart = new Function('event.returnValue=false'); //防止拖动
document.body.appendChild(heart).innerHTML = a[a_idx]; //将b元素添加到页面上
a_idx = (a_idx + 1) % a.length;
heart.style.cssText = "position: fixed;left:-100%;"; //给p元素设置样式
var f = 16, // 字体大小
x = event.clientX - f / 2, // 横坐标
y = event.clientY - f, // 纵坐标
c = randomColor(), // 随机颜色
a = 1, // 透明度
s = 1.2; // 放大缩小
var timer = setInterval(function () { //添加定时器
if (a <= 0) {
document.body.removeChild(heart);
clearInterval(timer);
} else {
heart.style.cssText = "font-size:16px;cursor: default;position: fixed;color:" +
c + ";left:" + x + "px;top:" + y + "px;opacity:" + a + ";transform:scale(" +
s + ");";
y--;
a -= 0.016;
s += 0.002;
}
}, 15)
}
// 随机颜色
function randomColor() {
return "rgb(" + (~~(Math.random() * 255)) + "," + (~~(Math.random() * 255)) + "," + (~~(Math
.random() * 255)) + ")";
}
}());
script>
body>
html>
代码如下
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Documenttitle>
head>
<body>
<script src="https://blog-static.cnblogs.com/files/axqa/fairyDustCursor.js">script>
<script src="https://blog-static.cnblogs.com/files/axqa/bubbleCursor.js">script>
<script src="https://blog-static.cnblogs.com/files/axqa/emojiCursor.js">script>
<script src="https://blog-static.cnblogs.com/files/axqa/snowflakeCursor.js">script>
<script src="https://blog-static.cnblogs.com/files/axqa/cursor-effects.js">script>
body>
html>
引用了别人的线上脚本文件,可以借鉴使用
点击下载
链接:https://pan.baidu.com/s/1k03aNiNEyjo–VZ5IAcM6g
提取码:gq8v