Pen Settings

HTML

CSS

CSS Base

Vendor Prefixing

Add External Stylesheets/Pens

Any URLs added here will be added as <link>s in order, and before the CSS in the editor. You can use the CSS from another Pen by using its URL and the proper URL extension.

+ add another resource

JavaScript

Babel includes JSX processing.

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

Packages

Add Packages

Search for and use JavaScript packages from npm here. By selecting a package, an import statement will be added to the top of the JavaScript editor for this package.

Behavior

Auto Save

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.

Format on Save

If enabled, your code will be formatted when you actively save your Pen. Note: your code becomes un-folded during formatting.

Editor Settings

Code Indentation

Want to change your Syntax Highlighting theme, Fonts and more?

Visit your global Editor Settings.

HTML

              
                <svg viewBox="0 0 400 400" xmlns="http://www.w3.org/2000/svg">
  <style>
circle {
  animation: swapText 20s linear infinite;
}

@keyframes swapText {
  0%, 3.3333333333% {
    opacity: 1;
  }
  3.33333333330001%, 100% {
    opacity: 0;
  }
}
  </style>
  <script>
    // You can actually strip this JS from the output `console.info`
    
    // random number between 0 and n rounded to 2 decimal places
    const r = (n) => Math.round((Math.random() * n + Number.EPSILON) * 100) / 100;
    const n = 30;
    const dur = 20;
    const s = document.querySelector("svg");
    const circle = document.createElementNS('http://www.w3.org/2000/svg', 'circle');
    for (let i = 0; i < n; i++) {
      const circ = circle.cloneNode();
      circ.setAttribute("cx", r(400));
      circ.setAttribute("cy", r(400));
      circ.setAttribute("r", r(200));
      circ.setAttribute("fill", `rgb(${r(255)}, ${r(255)}, ${r(255)})`);
      circ.style.animationDelay = `-${dur / n * i}s`;
      s.appendChild(circ);
    }
  </script>
</svg>
              
            
!

CSS

              
                // $n: 30;
// $dur: 3s;

// circle {
//   animation: swapText $dur linear infinite;
// }

// @for $i from 1 to $n + 1 {
//   circle:nth-of-type(#{$i}) {
//     animation-delay: #{($dur / $n) * $i};
//   }
// }

// @keyframes swapText {
//   0%,
//   #{100 / $n}% {
//     opacity: 1;
//   }

//   #{100 / $n}0001%,
//   100% {
//     opacity: 0;
//   }
// }

              
            
!

JS

              
                console.clear();

const support_firefox = true;

// Get our SVG values
const svg = document.querySelector("svg");
const viewboxValues = svg.getAttribute("viewBox").split(" ");
const width = svg.getAttribute("width") || viewboxValues[2];
const height = svg.getAttribute("height") || viewboxValues[3];

// Encode function from Yoksel: https://codepen.io/yoksel/pen/MWKeKK?editors=0010
const encoded_svg = encodeSVG(svg.outerHTML);

// Create the template
let info_template = `padding-left:${width}px;background-repeat:no-repeat;background-image:url("data:image/svg+xml,${encoded_svg}")`;
if (support_firefox) {
  info_template = `line-height:${height}px;padding-block:${height / 2}px;` + info_template;
} else {
  info_template = `padding-top:${height}px;` + info_template;
}

// For easy copy-paste into your site:
console.info(`
console.info(
  "%c ",
  \`${info_template}\`
);
`);

// For the preview:
console.info(
  "%c ",
  info_template
);

              
            
!
999px

Console