Skip to content
Advertisements

JavaScript Mouse Move




HTML AND JS CODE:

<!DOCTYPE html>

<html>
<head>
    <meta charset="utf-8" />
    <title>page</title>
    <link rel="stylesheet" type="text/css" href="2.page.css">
    <link rel="stylesheet" href="https://use.fontawesome.com/releases/v5.5.0/css/all.css">
</head>
<body>

    <div class="pointer"></div>

    <script src="https://code.jquery.com/jquery-3.3.1.js"></script>
    <script>
        $(document).mousemove(function (e) {
            $(".pointer").css({ left: e.pageX, top: e.pageY });
        })
    </script>

</body>
</html>

CSS CODE:

body{
    margin:0;
    padding:0;
    background:#000;
    overflow:hidden
}
.pointer{
    position:absolute;
    top:50%;
    left:50%;
    width:40px;
    height:40px;
    background:rgba(255,255,255,.1);
    border:1px solid rgba(255,255,255,.1);
    border-radius:50%;
    transform:translate(-50%,-50%);
    pointer-events:none;
    box-sizing:border-box;
    transition:.2s;
}
Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.

%d bloggers like this: