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. If you link to another Pen, it will include the CSS from that Pen. If the preprocessor matches, it will attempt to combine them before processing.

+ 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 id="cursor"></div>
	<div id="stalker"></div>
  <a href="#">リンクエリアにマウスを乗せるとカーソルが大きくなります</a>
</body>
              
            
!

CSS

              
                body{
	position: relative;
  background:#f00;
  cursor: none; /*もともとあるカーソルは非表示に*/
  height:100vh;
}

a{
  display:inline-block;
  margin:40px;
}

/*カーソル要素*/
#cursor{
	position: fixed;

  /*丸の大きさと色の指定*/
  background: #fff;
  border-radius:10px;
	width: 20px;
	height: 20px;
	margin: -10px 0 0 -10px;/*真ん中にくるようにマイナスマージンで調整*/

  z-index: 2;/*一番手前に来るように*/
	pointer-events: none;/*クリックできなくなるのを防ぐため。noneで対応*/
	opacity: 0;
  transition: transform 0.1s;/*アニメーションの秒数指定*/
}

/*ちょっと遅れてついてくるストーカー要素*/
#stalker{
	position: fixed;

  /*丸の大きさと色の指定*/
	background: #00f;
  width: 60px;
	height: 60px;
  border-radius:30px;
  margin: -30px 0 0 -30px;/*真ん中にくるようにマイナスマージンで調整*/
  z-index: 1;/*カーソルの後ろに来るように*/
	pointer-events: none;/*クリックできなくなるのを防ぐため。noneで対応*/
	opacity: 0;
  transition: transform 0.5s;/*アニメーションの秒数指定*/
}

#cursor.active,
#stalker.active{
	transform: scale(1.4);
}
              
            
!

JS

              
                $(function(){
	
	//カーソル要素の指定
	var cursor=$("#cursor");
	//ちょっと遅れてついてくるストーカー要素の指定  
	var stalker=$("#stalker");
	
	//mousemoveイベントでカーソル要素を移動させる
	$(document).on("mousemove",function(e){
    //カーソルの座標位置を取得
		var x=e.clientX;
		var y=e.clientY;
		//カーソル要素のcssを書き換える用
		cursor.css({
			"opacity":"0.9",
			"top":y+"px",
			"left":x+"px"
		});
		//ストーカー要素のcssを書き換える用    
		setTimeout(function(){
			stalker.css({
				"opacity":"0.4",
	  		"top":y+"px",
		  	"left":x+"px"
			});
		},140);//カーソルより遅れる時間を指定
  });
	//aタグホバー
	$("a").on({
		"mouseenter": function() {
			//activeクラス付与
			cursor.addClass("active");
			stalker.addClass("active");
		},
		"mouseleave": function() {
			cursor.removeClass("active");
			stalker.removeClass("active");
			
		}
	});
});
              
            
!
999px

Console