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 id="to-be-animated">ray</div>
</main>

<p id="support-message">Demo needs support for <code>offset-path</code> and the <code>ray()</code> function. Currently available in Chrome Canary 64+.</p>

<form>
  <p>
    <input type="checkbox" checked id="path-play-state"/>
    <label for="path-play-state">
      Animate <code>offset-path</code>
    </label>
  </p>
  <p>
    <input type="checkbox" checked id="distance-play-state"/>
    <label for="distance-play-state">
      Animate <code>offset-distance</code>
    </label>
  </p>
</form>

            
          
!
            
              :root {
  --radius: 20vmin;
}
div {
  --path-play-state: running;
  --distance-play-state: running;
  --anchor-x: 50%;
  --anchor-y: 50%;
  --position-x: 50%;
  --position-y: 50%;
  --offset-size: sides;

  offset-anchor: 
    var(--anchor-x)
    var(--anchor-y);
  offset-position: 
    var(--position-x)
    var(--position-y);
  
  offset-path: ray(0deg var(--offset-size));
  
  offset-distance: 0vmin;
  /* Chrome 64 does not respect the containing block yet it seems, so need to set as position absolute and use fixed units for offset-distance */
  position: absolute;
  top: 50%;
  left: 50%;
  
  animation: 
    distance 1000ms infinite alternate ease-in-out,
    angle 3000ms infinite linear;
  animation-play-state:
    var(--distance-play-state),
    var(--path-play-state);
}

@keyframes angle {
  100% {
    offset-path: ray(360deg var(--offset-size));
  }
}
@keyframes distance {
  100% {
    offset-distance: var(--radius);
  }
}

div {
  background: hsl(3, 90%, 50%);
  width: calc(var(--radius) / 2.5);
  height: calc(var(--radius) / 2.5);
  opacity: 1;
  
  -webkit-clip-path: polygon(20% 0%, 80% 0%, 100% 100%, 0% 100%);
  clip-path: polygon(20% 0%, 80% 0%, 100% 100%, 0% 100%);
  
  display: flex;
  justify-content: center;
  align-items: center;
  font-size: calc(var(--radius) / 8);
}

main {
  height: calc(var(--radius) * 2);
  width: calc(var(--radius) * 2);
  border: .6vmin dashed hsl(183, 28%, 75%);
  display: flex;
  justify-content: center;
  align-items: center;
  border-radius: 50%;
  position: relative;
  background: radial-gradient(circle, hsl(183,28%,75%) .6vmin, transparent .6vmin);
}







form {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  text-align: center;
  display: flex;
  align-items: center;
  justify-content: center;
  background: hsla(183,28%,95%,.2);
}
form p {
  padding: .5rem .75rem;
}
code {
  font-family: monospace;
}
body {
  min-height: 100vh;
  display: flex;
  justify-content: center;
  align-items: center;
  overflow: hidden;
  background: radial-gradient(circle,
    hsl(183, 90%, 30%) calc(var(--radius) / 2),
    hsl(183, 90%, 25%) calc(var(--radius) / 2),
    hsl(183, 90%, 25%) calc(var(--radius) * 1.5),
    hsl(183, 90%, 20%) calc(var(--radius) * 1.5)
  );
  font-family: system-ui, -apple-system, 'Segoe UI', sans-serif;
  color: hsl(183,28%,95%);
}
*, *::before, *::after {
  box-sizing: border-box;
}

main {
  display: none;
}
.supported main {
  display: flex;
}
#support-message {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  text-align: center;
  padding: .75rem;
  line-height: 1.35;
}
.supported #support-message {
  display: none;
}
            
          
!
            
              //Just for form element to play/pause animations

const toggles = Array.from(document.querySelectorAll('input[type=checkbox]'));
const animated = document.getElementById('to-be-animated');

toggles.forEach(toggle => {
  toggle.addEventListener('click', e => {
    animated.style.setProperty(
      `--${toggle.id}`,
      toggle.checked ? 'running' : 'paused'
    );
  });
});

if (window.CSS && CSS.supports && CSS.supports('offset-path', 'ray(0deg sides)')) {
  document.documentElement.classList.add('supported');
}
            
          
!
999px
Loading ..................

Console