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


Babel is required to process package imports. If you need a different preprocessor remove all packages first.

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


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.

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.


<div class="slideshow-container">
  <div class="image-container js-image-container">
    <img src="" alt="">
    <img src="" alt="">
    <img src="" alt="">
    <img src="" alt="">



.slideshow-container {
  max-width: 100%;
  height: 300px;
  overflow: hidden;
  white-space: nowrap;

.image-container {
  width: auto;
  height: 300px;
  white-space: nowrap;
  font-size: 0;
  display: inline-block;
  overflow: hidden;

  img {
    display: inline;
    height: 300px;
  &.is-animated {
    backface-visibility: hidden;
    perspective: 1000;
    animation: scroll-animation 12s linear infinite forwards;

@keyframes scroll-animation {
  0% {
    transform: translate3d(0, 0, 0);
  100% {
    transform: translate3d(var(--base-image-group-width), 0, 0);



                const container = document.querySelector('.js-image-container');
const parent = container.parentNode;
const images = container.querySelectorAll('img');

const insertImage = (container, images, index) => {
  const imageToInsert = images.item(index % images.length);
  const newDomEl = imageToInsert.cloneNode();
const parentWidth = parent.clientWidth;

let containerWidth = container.clientWidth;
// max of 100 images to prevent some stupid infinite loop
let i;
let appendedImage = false;
for (i = 0; i < 100; i++) {
  // stop when we filled at least 100% of parent
  console.log(containerWidth, parentWidth);
  if (containerWidth > parentWidth) {
  // insert image
  appendedImage = true;
  insertImage(container, images, i);
  containerWidth = container.clientWidth;

// Width of images at the time that whole parent was filled
const baseImageGroupWidth = container.clientWidth; 

// now duplicate images as to maintain illusion of infinity
const baseImages = container.querySelectorAll('img');
for (let j = 0; j < baseImages.length; j++) {
  insertImage(container, images, i + j);

let resetTargetWidth = baseImageGroupWidth;
if (appendedImage) {
  resetTargetWidth -= images.item(0).clientWidth; 
}'--base-image-group-width', `-${resetTargetWidth}px`);