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 class="demo">
  <div class="cell">
    <h2>SVG &lt;rect&gt;</h2>

    <svg version="1.1" id="svg" class="container" width="260" height="200"  xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" viewBox="0 0 260 200" xml:space="preserve">
        <rect id="svgRectangle" class="animated" x="20" y="60" width="220" height="80" fill="#91e600" />
    </svg>
  </div>
  <div class="cell">
    <h2>&lt;div&gt;</h2>
    <div class="container" style="width:260px; height:200px; position:relative;">
      <div id="divRectangle" class="animated"></div>
      
    </div>
  </div>
</div>
<div id="nav">
  <h3 id="message"></h3>

<div id="slider" style = "width:465px; float:left"></div>
 <button id="play" class="dark-grey-button club-demo-button">play</button>
</div>
              
            
!

CSS

              
                

body {
  background-color: #1d1d1d;
  color: #999;
  font-family: Arial, sans-serif;
  margin-left:18px;
}
strong {
  color: #DDD;
}
h2 {
  font-size:3em;
  line-height:1em;
  margin-bottom:0.1em;
  color: white;
  font-weight: 400;
  margin-top: 5px;
}
a, a:hover, a:visited {
  color:#71B200;
}
.container {
  border: 1px solid #666666;
  overflow: hidden;
  background:black;
}
.demo {
  display: table;
  font-family: monospace;
}
.cell {
  display: table-cell;
  padding-right: 18px;
  position: relative;
  text-align: center;
}
#divRectangle {
  position: absolute;
}
#divRectangle {
  background-color: #91e600;
  width: 220px;
  height: 80px;
  top: 60px;
  left: 18px;
}

button#play {
 float:right;
  margin-top:-8px;
  margin-right:10px;
}

#nav {
  width:560px;
  margin:0px auto;
  
}

.demo {
  width:560px;
  margin:0px auto;
}
              
            
!

JS

              
                gsap.registerPlugin(TextPlugin);

var elements = $("#svgRectangle, #divRectangle"),
    message = $("#message"),
    tl = gsap.timeline({onUpdate:updateSlider, defauts:{duration: 1}});

gsap.defaults({ smoothOrigin: false });
//very basic TimelineLite code to animate elements and change the text.
//notice that both elements  (#divRectangle and #svgRectangle) both use the exact same tweens
tl.set(message, {text:'{rotation:360, transformOrigin:"50% 50%"}'})
  .to(elements, {rotation:360, transformOrigin:"50% 50%"}, "+=1")
  .set(message, {text:'{rotation:"+=360", transformOrigin:"right bottom"}'}, "+=1")
  .to(elements, {rotation:"+=360", transformOrigin:"right bottom"})
  .set(message, {text:'{scale:0, transformOrigin:"0px 0px"}'}, "+=1")
  .to(elements, {scale:0, transformOrigin:"0px 0px"})
  .set(message, {text:'{scale:1, transformOrigin:"100% 0%"}'}, "+=1")
  .to(elements, {scale:1, transformOrigin:"100% 0%"})
  .set(message, {text:'{scaleY:0, transformOrigin:"0% 50%"}'}, "+=1")
  .to(elements, {scaleY:0, transformOrigin:"0% 50%"})
  .set(message, {text:'{scale:1, transformOrigin:"50% bottom"}'}, "+=1")
  .to(elements, {scale:1, transformOrigin:"50% bottom"})
  .set(message, {text:'{scale:0.5, rotation:360, transformOrigin:"50% 50%"}'}, "+=1")
  .to(elements, {scale:0.5, rotation:360, transformOrigin:"50% 50%"})




	$("#slider").slider({
            range: false,
            min: 0,
            max: 1,
			      step:0.001,
            slide: function ( event, ui ) {
                tl.progress( ui.value ).pause();
            }
     });	
			
	function updateSlider() {
		$("#slider").slider("value", tl.progress());
	}

$("#play").click(function(){
  if(tl.progress() === 1){
    tl.restart()
  } else {
    tl.play();
  }
})

tl.pause();


//be sure to test this in multiple browsers
              
            
!
999px

Console