Pen Settings

HTML

CSS

CSS Base

Vendor Prefixing

Add External Stylesheets/Pens

Any URL's added here will be added as <link>s in order, and before the CSS in the editor. You can use the CSS from another Pen by using it's URL and the proper URL extention.

+ add another resource

JavaScript

Babel includes JSX processing.

Add External Scripts/Pens

Any URL's added here will be added as <script>s in order, and run before the JavaScript in the editor. You can use the URL of any other Pen and it will include the JavaScript from that Pen.

+ add another resource

Packages

Add Packages

Search for and use JavaScript packages from npm here. By selecting a package, an import statement will be added to the top of the JavaScript editor for this package.

Behavior

Save Automatically?

If active, Pens will autosave every 30 seconds after being saved once.

Auto-Updating Preview

If enabled, the preview panel updates automatically as you code. If disabled, use the "Run" button to update.

Format on Save

If enabled, your code will be formatted when you actively save your Pen. Note: your code becomes un-folded during formatting.

Editor Settings

Code Indentation

Want to change your Syntax Highlighting theme, Fonts and more?

Visit your global Editor Settings.

HTML

              
                <body>
  <div class="cursor-fixed"></div>
  <div class="cursor">
    <div class="inside_cursor"></div>
  </div>
</body>
              
            
!

CSS

              
                body {
  background-color: black;
    cursor: none;
    .cursor {
        position: absolute;
        width: 30px;
        height: 30px;
        border-radius: 45px;
        border: 1px solid #D3D3D3;
        z-index: 9999;
        pointer-events: none;
    }
    .cursor-fixed {
        pointer-events: none;
        z-index: 300;
        position: absolute;
        width: 6px;
        height: 6px;
        border-radius: 45px;
        background: #E4E4E4;
    }
}
              
            
!

JS

              
                // handle the cool cursor
const $cursor = document.querySelector('.cursor')
const $insideCursor = document.querySelector('.inside_cursor')
const $body = document.querySelector('body')
let radius = 40
let cursorX = 0
let cursorY = 0
const event = 0

const mouse = { x: 0, y: 0 }

document.addEventListener('mousemove', (event) => {
    mouse.x = event.clientX - 15
    mouse.y = event.clientY - 15

})

// cool cursor 2
const $cursorPoint = document.querySelector('.cursor-fixed')
let cursorPointX = 0
let cursorPointY = 0

let mousePointX = 0;
let mousePointY = 0;

const loop = (event) => {
    window.requestAnimationFrame(loop)

    const newCursorX = cursorX + (mouse.x - cursorX) * 0.1
    const newCursorY = Math.floor(cursorY + (mouse.y - cursorY) * 0.1 + (window.scrollY / 10))

    const distanceX = newCursorX - cursorX
    const distanceY = newCursorY - cursorY

    cursorX = newCursorX
    cursorY = newCursorY

    const scale = 1 + Math.hypot(distanceX, distanceY) / 15

    $cursor.style.transform = `translateX(${cursorX}px) translateY(${cursorY}px) scale(${scale})`

    // fixed

    mousePointX = mouse.x + 10
    mousePointY = mouse.y + 10 + window.scrollY
    $cursorPoint.style.transform = `translateX(${mousePointX}px) translateY(${mousePointY}px)`

}
loop()
              
            
!
999px

Console