Pen Settings



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


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


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.


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.


<div class="rect template" id="template1"></div>
<div class="rect template" id="template2"></div>
<div class="rect" id="rect"></div>


                body {
  background-color: #333;
  position: relative;

.rect {
  position: absolute;
  left: 0;
  right: 0;
  margin: 0 auto;
  width: 150px;
  height: 150px;

#rect {
  background-color: rgba(0, 255, 0, 0.5);
   outline: 1px solid transparent;
   border: 1px solid transparent;

.template {
  background-color: black;


var rect = document.getElementById("rect")

function shake(element, shakes, speed){
	var tl = new TimelineLite();
	TweenLite.set(element, {x:"+=0"}); // this creates a full _gsTransform on element
	var transforms = element._gsTransform;
  //store the transform values that exist before the shake so we can return to them later
  var initProps = {
  //shake a bunch of times
  for(var i = 0; i < shakes; i++){, speed ,{x:initProps.x + R(-4,4), y:initProps.y + R(-2,2), rotation:initProps.rotation + R(-5,5)})
  //return to pre-shake values, speed ,{x:initProps.x, y:initProps.y, scale:initProps.scale, rotation:initProps.rotation})
  return tl;


function R(max,min){return Math.random()*(max-min)+min};

// usage in a timeline :
var tl = new TimelineMax({repeat:-1, yoyo:true});

tl.from(rect, 0.5, {rotation:0, x:-200, opacity:0})
	.add(shake(rect, 20, 0.1), "+=0.25")
	.to(rect, 0.5, {scale:0.25, y:200, rotation:45}, "+=0.5")
	.add(shake(rect, 120, 0.01), "+=0.25")
  .to(rect, 0.5, {x:200, opacity:0}, "+=0.5")

TweenLite.set("#template2", {y:200, scale:0.25, rotation:45})