css Audio - Active file-generic CSS - Active Generic - Active HTML - Active JS - Active SVG - Active Text - Active file-generic Video - Active header Love html icon-new-collection icon-person icon-team numbered-list123 pop-out spinner split-screen star tv

Pen Settings

CSS Base

Vendor Prefixing

Add External Stylesheets/Pens

Any URL's added here will be added as <link>s in order, and before the CSS in the editor. If you link to another Pen, it will include the CSS from that Pen. If the preprocessor matches, it will attempt to combine them before processing.

+ add another resource

You're using npm packages, so we've auto-selected Babel for you here, which we require to process imports and make it all work. If you need to use a different JavaScript preprocessor, remove the packages in the npm tab.

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

Use npm Packages

We can make npm packages available for you to use in your JavaScript. We use webpack to prepare them and make them available to import. We'll also process your JavaScript with Babel.

⚠️ This feature can only be used by logged in users.

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.

HTML Settings

Here you can Sed posuere consectetur est at lobortis. Donec ullamcorper nulla non metus auctor fringilla. Maecenas sed diam eget risus varius blandit sit amet non magna. Donec id elit non mi porta gravida at eget metus. Praesent commodo cursus magna, vel scelerisque nisl consectetur et.

            
              <main>
  <svg viewBox="0 0 400 200">
    <path d="M50,150 C50,0 200,0 200,75 C200,150 350,150 350,0" fill="none"/>
  </svg>
  <div class="mover"></div>
</main>

<aside>
  <label for="anchor-x">X</label>
  <input type="range" id="anchor-x" value="50" min="0" max="100"/>
  <output id="output-x">50%</output>

  <label for="anchor-y">Y</label>
  <input type="range" id="anchor-y" value="50" min="0" max="100"/>
  <output id="output-y">50%</output>
</aside>
            
          
!
            
              :root {
  --duration: 9000ms;
}

svg, main {
  width: 400px;
  height: 200px;
  position: relative;
}
path {
  stroke: #d8d8dd;
  stroke-width: 2px;
}
svg {
  position: absolute;
}

.mover {
  --anchorX: 50%;
  --anchorY: 50%;
  
  position: absolute;
  height: 50px;
  width: 50px;
  background: hsla(183, 90%, 54%, .3);
  border: 2px solid hsl(183, 100%, 54%);
  border-right-color: hsl(43, 100%, 50%);
  border-left-color: hsl(343, 100%, 50%);
  
  display: flex;
  justify-content: center;
  align-items: center;
  color: white;
  offset-path: path("M50,150 C50,0 200,0 200,75 C200,150 350,150 350,0");
  offset-rotate: auto 90deg;
  offset-anchor: var(--anchorX) var(--anchorY);
  animation: move-along var(--duration) 0ms infinite alternate ease-in-out;
}
.mover::after {
  content: '';
  position: absolute;
  background: radial-gradient(circle at var(--anchorX) var(--anchorY), red 3px, transparent 3px) no-repeat;
  width: 100%;
  left: 0;
  bottom: 0;
  top: 0;
}

aside {
  display: none;
}

@supports (offset-anchor: 70% 70%) {
  aside {
    display: grid;
  }
}
/*
@supports (offset-position: 70% 70%) {
  #position {
    display: block;
  }
}
*/
@keyframes move-along {
  100% {
    offset-distance: 100%;
  }
}





body {
  min-height: 100vh;
  background: #16161c;
  font-family: system-ui, sans-serif;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  color: hsl(183,100%, 97%);
  padding: 2rem 0;
  box-sizing: border-box;
}
aside {
  margin: 0rem 1rem;
  grid-template-columns: 4em 1fr 4em;
  grid-gap: 1em;
}
label {
  text-align: right;
}
input {
  margin-bottom: 1rem;
}
output {
  opacity: .7;
}
            
          
!
            
              var x = document.getElementById('anchor-x');
var y = document.getElementById('anchor-y');
var outputx = document.getElementById('output-x');
var outputy = document.getElementById('output-y');
var mover = document.querySelector('.mover');

x.addEventListener('input', function(e) {
  let x = `${e.currentTarget.value}%`;
  mover.style.setProperty('--anchorX', x);
  outputx.textContent = x;
});
y.addEventListener('input', function(e) {
  let y = `${e.currentTarget.value}%`;
  mover.style.setProperty('--anchorY', y);
  outputy.textContent = y;
});
            
          
!
999px
🕑 One or more of the npm packages you are using needs to be built. You're the first person to ever need it! We're building it right now and your preview will start updating again when it's ready.
Loading ..................

Console