[编程]html网页实现osu光标[不含拖尾]

[编程]html网页实现osu光标[不含拖尾]

html部分:

<!DOCTYPE html>

<html lang=”en”>

<head>

    <meta charset=”UTF-8″>

    <meta http-equiv=”X-UA-Compatible” content=”IE=edge”>

    <meta name=”viewport” content=”width=device-width, initial-scale=1.0″>

    <title>osu光标</title>

    <link rel=”stylesheet” href=”https://www.mcydm.com/css.css”>

</head>

<body>

    <div class=”cursor” style=”display: none;”>

        <div class=”cursorCentre”>

            <img src=”https://www.mcydm.com/img/cursormiddle@2x.png” alt=””>

        </div>

        <div class=”cursorPeriphery”>

            <img src=”https://www.mcydm.com/img/cursor@2x.png” alt=””>

        </div>

    </div>

</body>

<script src=”https://www.mcydm.com/js.js”></script>

</html>

css部分:

* {

    cursor: none;

    margin: 0;

    padding: 0;

}

html {

    background-color: black;

}

.cursor {

    width: 120px;

    height: 120px;

    position: fixed;

    justify-content: center;

    align-items: center;

    pointer-events: none;

    user-select: none;

}

.cursorCentre {

    position: absolute;

    top: 42.5px;

    left: 42.5px;

}

.cursorCentre,

.cursorCentre img {

    width: 35px;

    height: 35px;

}

.cursorPeriphery {

    width: 90px;

    height: 90px;

}

.cursorPeriphery img {

    width: 100%;

    height: 100%;

}

.bigAnimation {

    animation-name: big;

    animation-fill-mode: forwards;

    animation-duration: .15s;

}

.littleAnimation {

    animation-name: little;

    animation-fill-mode: forwards;

    animation-duration: .15s;

}

@keyframes big {

    0% {

        width: 90px;

        height: 90px;

    }

    100% {

        width: 120px;

        height: 120px;

    }

}

@keyframes little {

    0% {

        width: 120px;

        height: 120px;

    }

    100% {

        width: 90px;

        height: 90px;

    }

}

js部分:

var cursor = document.getElementsByClassName(‘cursor’)[0]

var cursorPeriphery = document.getElementsByClassName(‘cursorPeriphery’)[0]

var mouseX;

var mouseY;

var angle = 0;

window.onmousemove = function (e) {

    mouseX = e.clientX;

    mouseY = e.clientY;

}

window.onmouseover = function () {

    cursor.style.display = ‘flex’;

}

window.onmouseout = function () {

    cursor.style.display = ‘none’;

}

window.onmousedown = function () {

    cursorPeriphery.className = ‘cursorPeriphery bigAnimation’;

}

window.onmouseup = function(){

    cursorPeriphery.className = ‘cursorPeriphery littleAnimation’;

}

function animation() {

    cursor.style.top = mouseY – 60 + ‘px’;

    cursor.style.left = mouseX – 60 + ‘px’;

    cursorPeriphery.style.transform = ‘rotate(‘ + angle++ +’deg)’

    requestAnimationFrame(animation)

}

animation()

代码/素材下载链接:

https://www.aliyundrive.com/s/JvT2dRrSXCq

此内容仅限会员查看,请先
资源来源于网络采集,若下载链接失效不补。
0
若功能无法使用
请使用谷歌浏览器
显示验证码
没有账号?注册  忘记密码?