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

              
                <main>
  <div class="reference"></div>
</main>

<header>
  <code><span class="property">transform:</span></code>
</header>

<footer>
  <p>
  Используйте JS-панель на CodePen для указания трансформации </p>
</footer>
              
            
!

CSS

              
                div {
  /* а также попробуйте разный transform-origin для толчков*/
  --transform-origin-x: 50%;
  --transform-origin-y: 50%;
  transform-origin: var(--transform-origin-x) var(--transform-origin-y); 
  
  --graph-color: hsla(183, 80%, 0%, .05);
  
  background-color: hsla(var(--hue, 183), 80%, 50%, var(--alpha, 1));
  
  width: var(--side);
  height: var(--side);
  position: absolute;
  top: 0;
  left: calc(var(--side) * -1);
  opacity: 0;
  mix-blend-mode: normal;
  
  background-image: 
    linear-gradient(to right,
      var(--graph-color) 0px, 
      var(--graph-color) 1px),
    linear-gradient(to bottom,
      var(--graph-color) 0px, 
      var(--graph-color) 1px);
  background-position: var(--transform-origin-x) var(--transform-origin-y);
  background-size: 2px 100%, 100% 2px;
  background-repeat: no-repeat;
  
  transition: opacity 200ms ease-in;
}
div:last-of-type {
  mix-blend-mode: normal;
}
main {
  position: relative;
  width: var(--side);
  height: var(--side);
  
  --side: 33vmin;
}

.reference {
  opacity: .3;
  background-color: hsla(183, 80%, 0%, .15);
  border: 3px dashed hsl(183, 80%, 0%);
}

body {
  min-height: 100vh;
  display: flex;
  justify-content: center;
  align-items: center;
  overflow: hidden;
  background: hsl(183, 80%, 98%);
  
  --graph-color: hsl(0,0%,95%); 
  background-image: 
    repeating-linear-gradient(to right, 
      var(--graph-color) 0px, 
      var(--graph-color) 1px, 
      transparent 1px, 
      transparent 1vmin),
    repeating-linear-gradient(to bottom, 
      var(--graph-color) 0px, 
      var(--graph-color) 1px, 
      transparent 1px, 
      transparent 1vmin);
}
*, *::before, *::after {
  box-sizing: border-box;
}
header {
  position: absolute;
  top: 0;
  right: 0;
  left: 0;
  text-align: center;
  padding: 1rem;
  font-size: calc(2vmin + .5rem);
  font-family: monospace;
}
header span {
  display: inline-block;
  padding: .5rem 0 .25rem;
  background: linear-gradient(to right, 
    hsla(var(--hue, 183), 80%, 50%, var(--hue, 0)), 
    hsla(var(--hue, 183), 80%, 50%, var(--hue, 0))) left bottom no-repeat;
  background-size: 100% 20%;
  transition: background 200ms linear;
  margin-right: .75rem;
}
footer {
  position: absolute;
  bottom: 0;
  right: 0;
  left: 0;
  text-align: center;
  padding: 2vmin;
  font-size: calc(1vmin + .5rem);
  font-family: system-ui, 'Segoe UI', -apple-system, sans-serif;
}
              
            
!

JS

              
                //добавляйте/удаляйте transform-ы или изменяйте их, меняя этот масив и запуская её снова
const transforms = [
  'translateX(66vmin)',
  'rotate(.125turn)',
  'scale(.5)',
  'translateY(66vmin)',
];

var main = document.querySelector('main');
var description = document.querySelector('header');

const opacityBase = transforms.length + 1;
const duration = 2000;
const endOpacity = 1;

const hues = [183, 43, 143, 343, 283];

var divs = [];
var descriptions = [];

transforms.forEach(function(t) {
  let div = document.createElement('div');
  let span = document.createElement('span');
  span.textContent = t;
  
  divs.push(div);
  descriptions.push(span);
  
  main.appendChild(div);
  description.appendChild(span);
});

animateIt(0);

function animateIt(i) {
  var el = divs[i];
  var hue = hues[i % hues.length]
  descriptions[i].style.setProperty('--hue', hue);
  el.style.setProperty('--hue', hue);
  el.style.setProperty('--alpha', (i+1)/opacityBase);
  
  var start = transforms.reduce(function(result, transform, index) {
    return index < i ? result + ' ' + transform : result;
  }, '').trim();
  
  el.style.opacity = endOpacity;
  var animation = el.animate([
    { transform: start || 'translateX(0)' },
    { transform: (start ? start + ' ' : '') + transforms[i] }
  ], {
    fill: 'forwards',
    duration: duration,
    easing: 'ease-out'
  });
  
  if (i < transforms.length - 1) {
    animation.onfinish = function() { animateIt(i+1) };
  }
}
              
            
!
999px

Console