cssAudio - Activefile-genericCSS - ActiveGeneric - ActiveHTML - ActiveImage - ActiveJS - ActiveSVG - ActiveText - Activefile-genericVideo - ActiveLovehtmlicon-new-collectionicon-personicon-teamlog-outoctocatpop-outspinnerstartv

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.

Quick-add: + add another resource

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.

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.

            
              <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
Loading ..................

Console