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 id="nav">
  <button class="btn-blue" id="rotateOuterBtn">Run Animation using Outer Element</button>
  <button class="btn-blue" id="rotateInnerBtn">Run Animation using Inner Element</button>
  <button class="btn-blue" id="rotateInnerLeftTopBtn">Run Animation using Outer Element & Left Top</button>
  <button class="btn-white" id="resetMatrix">Reset Original Matrix</button>
</div>  

<div class="divLayers">
  <div class="slide_layer" id="rotateIn" style="left: 300px; top: 70px; opacity: 1; transform: matrix(0.707107, 0.707107, -0.707107, 0.707107, 0, 0);">
    <div class="outerslide_layer">
      <div class="innerslide_layer">
        <svg class="add-shape" preserveAspectRatio="none" id="square" viewBox="0 0 202 202" version="1.1" width="150" height="150">
          <path class="shape-color shape-stroke color-1" d="M 201,201 1,201 1,1 l 200,0 0,200 z" style="fill:#ffffff;stroke:#000000;stroke-width:2px"></path>
        </svg>
      </div>
    </div>
  </div>
</div>

              
            
!

CSS

              
                body{
  font-family: Arial, Helvetica, sans-serif;
  color:white;
  background:black url(//s.cdpn.io/16327/texture_bg.jpg) no-repeat 50% 0px;
  margin:5% 15% 0 15%;
  overflow:hidden;
}
.divLayers {
  background: rgba(255, 255, 255, 0.3);
  overflow: visible;
  position: relative;
  z-index: 50;
  height: 260px;
  font-size: 12px;
  color: #222;
  white-space: nowrap;
  font-family: 'Open Sans';
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}
.slide_layer {
  position: absolute;
  bottom: auto;
  right: auto;
}
.outerslide_layer {
  position: relative;
}

.btn-blue {
  margin: 0 3px 10px;
  background: #263456;
  color: white;
  border: none;
  box-shadow: 0 0 2px #F2F2F2;
  padding: 3px 10px;
}
.btn-white {
  background: white;
  color: #263456;
  box-shadow: 0 0 2px #263456;
  padding: 3px 10px;
  border: none;
}
              
            
!

JS

              
                var rotateOuterBtn          = document.getElementById('rotateOuterBtn'),
    rotateInnerBtn          = document.getElementById('rotateInnerBtn'),
    rotateInnerLeftTopBtn   = document.getElementById('rotateInnerLeftTopBtn'),
    resetMatrixBtn          = document.getElementById('resetMatrix'),
    rotatedEl               = document.getElementById('rotateIn'),
    innerEl                 = rotatedEl.querySelector('.innerslide_layer'),
    originalMatrix          = 'matrix(0.707107, 0.707107, -0.707107, 0.707107, 0, 0)',
    tl                      = new TimelineLite(),
    leftTopTl               = new TimelineLite({onComplete: onCustomAnimComplete});

// Rotate using Outer Element
rotateOuterBtn.onclick = function(event)
{  
  cleanUp();
  
  // Set Default Rotation
  tl.set(rotatedEl, {rotation: "+=360"});
  
  tl.from(rotatedEl, .4, {
    x:        -550,
    opacity:  0,
    rotation: "-=360"
  });
  
  tl.play();
};

// Rotate using Inner Element
rotateInnerBtn.onclick = function(event)
{  
  cleanUp();
  
  // Set Default Rotation
  tl.set(innerEl, {rotation: 360});
  
  tl.from(innerEl, .4, {
    x:        -550,
    opacity:  0,
    rotation: 0
  });
  
  tl.to(innerEl, .4, {
    x:        0,
    opacity:  1,
    rotation: 360
  });
  
  tl.play();
};

// Rotate using Inner Element Left Top
rotateInnerLeftTopBtn.onclick = function(event)
{      
  cleanUpCustom();
  
  innerEl.style.position = 'absolute';
  
  // Set Default Rotation
  leftTopTl.set(rotatedEl, {rotation: 360});
  
  leftTopTl.from(rotatedEl, .4, {
    left:     '-550px',
    opacity:  0,
    rotation: 0
  });
  
  leftTopTl.to(rotatedEl, .4, {
    left:     '300px',
    opacity:  1,
    rotation: 360
  });
  
  leftTopTl.play();
};

// Run timeline cleanup
function cleanUp()
{
  tl.clear().time(0);
}

function cleanUpCustom()
{
  leftTopTl.clear().time(0);
}

function onCustomAnimComplete()
{
  innerEl.style.position = '';
}

resetMatrixBtn.onclick = function(event)
{
  rotatedEl.style.transform = originalMatrix;
};
              
            
!
999px

Console