よくみる U I 検証会
02.カーソルのカスタム
Demo
ページ内のカーソルを参照してください。
Source
                            <div id="cursor"></div>
                        
                        
                            html,body,a{
                            	cursor: none;
                            }
                            #cursor {
                            	transform: translate(0, 0);
                            	pointer-events: none;
                            	position: fixed;
                            	top: -6px;
                            	left: -6px;
                            	width: 12px;
                            	height: 12px;
                            	background: rgba(217, 217, 217, 0.75);
                            	border-radius: 50%;
                            	z-index: 999;
                            	transition: width .3s, height .3s, top .3s, left .3s;
                            }
                            #cursor.hover {
                            	top: -16px;
                            	left: -16px;
                            	width: 36px;
                            	height: 36px;
                            	background: rgba(123,104,50,0.75);
                            }
                        
                        
                            const cursor = document.getElementById('cursor');
                            document.addEventListener('mousemove',  (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', (e) => {
                            		cursor.classList.add('hover');
                            	});
                            	linkElem[i].addEventListener('mouseout', (e) => {
                            		cursor.classList.remove('hover');
                            	});
                            }
                        
                    @2021 unisuke