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

              
                <!-- Update 10/7/2013 11am: user https://codepen.io/rafaelcastrocouto/details/sAqFj showed me his, which uses a cubic-bezier timing function instead. Looks more like the gif. Thanks! -->


<div class="controls">
	<button class="toggle" data-status="active">Hide Tracks</button>
	<button class="toggle-rotate" data-status="inactive"> Rotate</button>
</div>
<p>Based on <a href="https://i.imgur.com/woJeJbz.gif">this super cool illusion</a></p>
<p>If you look closely, the circles aren't rotating at all. They're moving up and down each respective axis, delayed by .25 seconds each. Cool, right?</p>
<p><small>For added effect, the circle can also rotate.<br /> You can toggle that.</small></p>

<div class="circle tracks">
	<div class="line line1"></div>
	<div class="line line2"></div>
	<div class="line line3"></div>
	<div class="line line4"></div>
	<div class="line line5"></div>
	<div class="line line6"></div>
	<div class="line line7"></div>
	<div class="line line8"></div>
		<div class="track track1">
			<div class="dot"></div>
		</div>
		<div class="track track2">
			<div class="dot"></div>
		</div>
		<div class="track track3">
			<div class="dot"></div>
		</div>
		<div class="track track4">
			<div class="dot"></div>
		</div>
		<div class="track track5">
			<div class="dot"></div>
		</div>
		<div class="track track6">
			<div class="dot"></div>
		</div>
		<div class="track track7">
			<div class="dot"></div>
		</div>
		<div class="track track8">
			<div class="dot"></div>
		</div>
</div>
              
            
!

CSS

              
                
body{
	background: #f0f0f0;
  font-family:sans-serif;
}
a{
  text-decoration:none;
  color:#08C;
  &:hover{
    color:lighten(#08C, 10%)
  }
}
p{
  max-width:500px;
  font-size:0.9em;
  &:hover{
    position:relative;
    z-index:999;
    background:#fff;
  }
}
.circle{
	position: absolute;
	left:50%;
	top:50%;
	margin-left:-250px;
	margin-top:-250px;
	width:500px;
	height:500px;
	background-color:#222;
	background-image:-webkit-radial-gradient(top, circle, #333, #111);
		background-image:-moz-radial-gradient(top, circle, #333, #111);
			background-image:radial-gradient(top, circle, #333, #111);
	border-radius:100%;
}
	.rotate{
		-webkit-animation-name: turn;
		-moz-animation-name: turn;
		animation-name: turn;
	    -webkit-animation-duration: 30000ms;
	    -moz-animation-duration: 30000ms;
	    animation-duration: 30000ms;
	    -webkit-animation-iteration-count: infinite;
	    -moz-animation-iteration-count: infinite;
	    animation-iteration-count: infinite;
	    -webkit-animation-timing-function: linear;
	    -moz-animation-timing-function: linear;
	    animation-timing-function: linear;
	}

.line{
	position: absolute;
	top:50%;
	-webkit-transform:translate(-50% -50%);
	-moz-transform:translate(-50% -50%);
	transform:translate(-50% -50%);
	width:100%;
	height:1px;
}
	.tracks{
		.line{
			background:rgba(255,255,255,0.2);
			box-shadow:rgba(0,0,0,0.5) 0px 1px 0px;
		}
	}

.line2{
	-webkit-transform:rotate(22.5deg);
	-moz-transform:rotate(22.5deg);
	transform:rotate(22.5deg);
}
.line3{
	-webkit-transform:rotate(45deg);
	-moz-transform:rotate(45deg);
	transform:rotate(45deg);
}
.line4{
	-webkit-transform:rotate(67.5deg);
	-moz-transform:rotate(67.5deg);
	transform:rotate(67.5deg);
}
.line5{
	-webkit-transform:rotate(90deg);
	-moz-transform:rotate(90deg);
	transform:rotate(90deg);
}
.line6{
	-webkit-transform:rotate(112.5deg);
	-moz-transform:rotate(112.5deg);
	transform:rotate(112.5deg);
}
.line7{
	-webkit-transform:rotate(135deg);
	-moz-transform:rotate(135deg);
	transform:rotate(135deg);
}
.line8{
	-webkit-transform:rotate(157.5deg);
	-moz-transform:rotate(157.5deg);
	transform:rotate(157.5deg);
}

.track{
	position: absolute;
	top:50%;
	-webkit-transform:translate(-50% -50%);
	-moz-transform:translate(-50% -50%);
	transform:translate(-50% -50%);
	width:100%;
	height:1px;
}

.track2{
	-webkit-transform:rotate(22.5deg);
	-moz-transform:rotate(22.5deg);
	transform:rotate(22.5deg);
}
.track3{
	-webkit-transform:rotate(45deg);
	-moz-transform:rotate(45deg);
	transform:rotate(45deg);
}
.track4{
	-webkit-transform:rotate(67.5deg);
	-moz-transform:rotate(67.5deg);
	transform:rotate(67.5deg);
}
.track5{
	-webkit-transform:rotate(90deg);
	-moz-transform:rotate(90deg);
	transform:rotate(90deg);
}
.track6{
	-webkit-transform:rotate(112.5deg);
	-moz-transform:rotate(112.5deg);
	transform:rotate(112.5deg);
}
.track7{
	-webkit-transform:rotate(135deg);
	-moz-transform:rotate(135deg);
	transform:rotate(135deg);
}
.track8{
	-webkit-transform:rotate(157.5deg);
	-moz-transform:rotate(157.5deg);
	transform:rotate(157.5deg);
}

.dot{
	position: absolute;
	width:15px;
	height:15px;
	background-color:#f8f8f8;
	background-image:-webkit-radial-gradient(circle, #fff, #f0f0f0);
	background-image:-moz-radial-gradient(circle, #fff, #f0f0f0);
	background-image:radial-gradient(circle, #fff, #f0f0f0);
	border-radius:100%;
	box-shadow:rgba(0,0,0,0.5) 0px 0px 4px;
	top:50%;
	left:5%;
	margin-top:-7.5px;
	z-index:9999;
}
  .dot-init{
    	-webkit-animation:spin 2.75s infinite;
	    -moz-animation:spin 2.75s infinite;
	    animation:spin 2.75s infinite;
      -webkit-animation-timing-function:cubic-bezier(0.5, 0, 0.5, 1);
      -moz-animation-timing-function:cubic-bezier(0.5, 0, 0.5, 1);
      animation-timing-function:cubic-bezier(0.5, 0, 0.5, 1);
  }

.track2 .dot{
	-webkit-animation-delay: .25s;
	-moz-animation-delay: .25s;
	animation-delay: .25s;
}
.track3 .dot{
	-webkit-animation-delay: .40s;
	-moz-animation-delay: .40s;
	animation-delay: .40s;
}
.track4 .dot{
	-webkit-animation-delay: .55s;
	-moz-animation-delay: .55s;
	animation-delay: .55s;
}
.track5 .dot{
	-webkit-animation-delay: .70s;
	-moz-animation-delay: .70s;
	animation-delay: .70s;
}
.track6 .dot{
	-webkit-animation-delay: .85s;
	-moz-animation-delay: .85s;
	animation-delay: .85s;
}
.track7 .dot{
	-webkit-animation-delay: 1.0s;
	-moz-animation-delay: 1.0s;
	animation-delay: 1.0s;
}
.track8 .dot{
	-webkit-animation-delay: 1.15s;
	-moz-animation-delay: 1.15s;
	animation-delay: 1.15s;
}

@-webkit-keyframes spin{
	0% { left:5%; }
	50% { left:95%; }
	100% { left:5%;}
}
@-moz-keyframes spin{
	0% { left:5%; }
	50% { left:95%; }
	100% { left:5%;}
}
@keyframes spin{
	0% { left:5%; }
	50% { left:95%; }
	100% { left:5%;}
}


@-webkit-keyframes turn{
	0% { -webkit-transform:rotate(0); -moz-transform:rotate(0); transform:rotate(0); }
	100% { -webkit-transform:rotate(360deg); -moz-transform:rotate(360deg); transform:rotate(360deg); }
}
              
            
!

JS

              
                		$(function(){
      
      $(".dot").each(function(key,value){
        $(value).addClass("dot-init");
      });
      
			$(".toggle").click(function(){
				if ($(this).data("status") === "inactive"){
					$(this).data("status", "active");
					$(".circle").addClass("tracks");
					$(this).html("Hide Tracks");
				}
				else{
					$(this).data("status", "inactive");
					$(".circle").removeClass("tracks");
					$(this).html("Show Tracks");
				}
			});
			$(".toggle-rotate").click(function(){
				if ($(this).data("status") === "inactive"){
					$(this).data("status", "active");
					$(".circle").addClass("rotate");
					$(this).html("Stop Rotating");
				}
				else{
					$(this).data("status", "inactive");
					$(".circle").removeClass("rotate");
					$(this).html("Rotate");
				}
			});
		});
              
            
!
999px

Console