cssAudio - Activefile-genericCSS - ActiveGeneric - ActiveHTML - ActiveImage - ActiveJS - ActiveSVG - ActiveText - Activefile-genericVideo - Activehtmlicon-personicon-teamoctocatspinnerstartv

Pen Settings

CSS Base

Vendor Prefixing

Add External CSS

These stylesheets will be added in this order and before the code you write in the CSS editor. You can also add another Pen here, and it will pull the CSS from it. Try typing "font" or "ribbon" below.

Quick-add: + add another resource

Add External JavaScript

These scripts will run in this order and before the code in the JavaScript editor. You can also link to another Pen here, and it will run the JavaScript from it. Also try typing the name of any popular library.

Quick-add: + add another resource

Code Indentation

     

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.

            
              <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>
            
          
!
            
              

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;
}
            
          
!
            
              var elements = $("#svgRectangle, #divRectangle"),
    message = $("#message"),
    tl = new TimelineMax({onUpdate:updateSlider});

CSSPlugin.defaultSmoothOrigin = 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, 1, {rotation:360, transformOrigin:"50% 50%"}, "+=1")
  .set(message, {text:'{rotation:"+=360", transformOrigin:"right bottom"}'}, "+=1")
  .to(elements, 1, {rotation:"+=360", transformOrigin:"right bottom"})
  .set(message, {text:'{scale:0, transformOrigin:"0px 0px"}'}, "+=1")
  .to(elements, 1, {scale:0, transformOrigin:"0px 0px"})
  .set(message, {text:'{scale:1, transformOrigin:"100% 0%"}'}, "+=1")
  .to(elements, 1, {scale:1, transformOrigin:"100% 0%"})
  .set(message, {text:'{scaleY:0, transformOrigin:"0% 50%"}'}, "+=1")
  .to(elements, 1, {scaleY:0, transformOrigin:"0% 50%"})
  .set(message, {text:'{scale:1, transformOrigin:"50% bottom"}'}, "+=1")
  .to(elements, 1, {scale:1, transformOrigin:"50% bottom"})
  .set(message, {text:'{scale:0.5, rotation:360, transformOrigin:"50% 50%"}'}, "+=1")
  .to(elements, 1, {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
Close

Asset uploading is a PRO feature.

As a PRO member, you can drag-and-drop upload files here to use as resources. Images, Libraries, JSON data... anything you want. You can even edit them anytime, like any other code on CodePen.

Go PRO

Loading ..................

Console