Pen Settings

HTML

CSS

CSS Base

Vendor Prefixing

Add External Stylesheets/Pens

Any URLs 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 its URL and the proper URL extension.

+ 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

Auto Save

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

              
                <div id="cursor"></div>
<h1>
マウスカーソルをドットにする
</h1>

<div class="btn"><a href="">リンク</a></div>

              
            
!

CSS

              
                html,body,a{
  cursor: none;
}
#cursor{
  transform: translate(0,0);
    pointer-events: none;
    position: fixed;
    top: -4px;    //座標調節(カーソル位置と円の中心を合わせる)
    left: -4px;   //座標調節(カーソル位置と円の中心を合わせる)
    width: 8px;   //カーソルの直径
    height: 8px;  //カーソルの直径
    background: rgba(0,0,0,0.75);
    border-radius: 50%;
    z-index: 999;
    transition: width .3s, height .3s, top .3s, left .3s;
  
  &.hov_{
    top: -12px;    //大きくなった分の座標調節
    left: -12px;   //大きくなった分の座標調節
    width: 32px;   //カーソルの直径
    height: 32px;  //カーソルの直径
    background: rgba(200,50,50,0.75);
  }
}

// 以下、カーソルに関係ない部分
.btn {
    display: block;
    width: 160px;
    margin: 40px auto;
    text-align: center;
    font-size: 14px;
    line-height: 1;

    a {
      display: block;
      color: #fff;
      text-decoration: none;
      padding: 8px;
      background-color: #007adf;
    }

}
              
            
!

JS

              
                //準備
let cursorR = 4;  //カーソルの半径
const cursor = document.getElementById('cursor');  //カーソル用のdivを取得

//上記のdivタグをマウスに追従させる処理
document.addEventListener('mousemove', function (e) {
    cursor.style.transform = 'translate(' + e.clientX + 'px, ' + e.clientY + 'px)';
});

//リンクにホバー時はクラスをつける
const linkElem = document.querySelectorAll('a');
for (let i = 0; i < linkElem.length; i++) {
    linkElem[i].addEventListener('mouseover', function (e) {
        cursor.classList.add('hov_');
    });
    linkElem[i].addEventListener('mouseout', function (e) {
        cursor.classList.remove('hov_');      
    });
}
              
            
!
999px

Console