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>
  <div></div>
  <div></div>
  <div></div>
  <div></div>
  <div></div>
  <div class="cover"></div>
</main>

            
          
!
            
              :root {
  --pixel: 1px;
  --cover: black;
  --duration: 500ms;
  --covered: calc(var(--pixel) * 4); /*5 frames, 4 covered at a time */
  --space: white; /* will cause transparency when mix blend mode multiply */
  --w: 240px;
  --h: 160px;
  
  --direction: normal;
  --blend: multiply;
}
main div {
  --offset: calc(var(--pixel) * 1);
  --ball-position: 0% 60%;
  
  position: absolute;
  top: 0;
  right: 0;
  bottom: 0;
  left: 0;
  overflow: hidden;
  
  background: 
    linear-gradient(to right, 
      transparent 0, transparent calc(var(--pixel)), 
      var(--space) var(--pixel), var(--space) calc(var(--covered))),
    radial-gradient(circle at var(--ball-position), 
      hotpink 0px, hotpink 45px, white 55px);
  mix-blend-mode: var(--blend);
  
  background-position: calc(var(--offset) - calc(var(--pixel) * 1)) 0, center center;
  background-size: calc(var(--pixel) * 5) 100%, 100% 100%;
  
  transform: translateX(52%);
}

main div:nth-of-type(2) {
  --offset: calc(var(--pixel) * 2);
  --ball-position: 25% 75%;
}
main div:nth-of-type(3) {
  --offset: calc(var(--pixel) * 3);
  --ball-position: 50% 60%;
}
main div:nth-of-type(4) {
  --offset: calc(var(--pixel) * 4);
  --ball-position: 75% 50%;
}
main div:nth-of-type(5) {
  --offset: calc(var(--pixel) * 5);
  --ball-position: 100% 60%;
}

.no-animation {
  --show: paused;
}


/*the sliding cover that triggers the motion illusion */
.cover {
  background: 
    linear-gradient(to right, 
      transparent 0px, transparent calc(var(--pixel) * 1), 
      var(--cover) calc(var(--pixel) * 1), 
      var(--cover) calc(var(--pixel) * 5));
  background-size: calc(var(--pixel) * 5) 100%;
  
  transform: translateX(-52%);
}

@keyframes slide {
  100% {
    transform: translateX(var(--covered));
  }
}


main {
  width: var(--w);
  height: var(--h);
  position: relative;
  transition: transform var(--duration) ease-in-out;
  background: white;
  transform: scale(1);
}
*, *::after {
  box-sizing: border-box;
}










body {
  width: 100%;
  min-height: 100vh;
  display: flex;
  justify-content: center;
  align-items: center;
  flex-direction: column;
  background: hsl(203, 50%, 98%);
  margin: 0;
  overflow: hidden;
  overflow-y: scroll;
  
  font-family: system-ui, 'Segoe UI', sans-serif
}

button {
  appearance: none;
  background: transparent;
  border: .1rem solid currentColor;
  margin-top:.5rem;
  padding: .5rem 1rem;
  font-size: 1rem;
  background: hsl(203, 50%, 94%);
}


            
          
!
            
              document.getElementById('go').addEventListener('click', function() {
  document.documentElement.classList.toggle('no-animation');
})
            
          
!
999px
Loading ..................

Console