Skip welcome & menu and move to editor
Welcome to JS Bin
Load cached copy from
 
<!DOCTYPE html>
<html>
<head>
  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width">
  <title>JS Bin</title>
</head>
<body>
  
<template id="template">
  <style>
    :host {
      display: inline-block;
      position: relative;
    }
    
    :host(.animate) {
      animation-duration: 2s;
      animation-iteration-count: infinite;
      animation-name: x-keyframes;
    }
    
    @keyframes x-keyframes {
      0% {
        left: 0px;
      }
      100% {
        left: 200px;
      }
    }
  </style>
  moving?
</template>
  
  <script>
    
    class XFoo extends HTMLElement {
      connectedCallback() {
        if (!this.shadowRoot) {
          this.attachShadow({mode: 'open'});
          this.shadowRoot.appendChild(document.importNode(template.content, true))
          setTimeout(() => this.classList.add('animate'), 1);
        }
      }
    }
    customElements.define('x-foo', XFoo);
  </script>
  
  
  <x-foo></x-foo>
  
</body>
</html>
Output

You can jump to the latest bin by adding /latest to your URL

Dismiss x
public
Bin info
sorvellpro
0viewers