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

              
                <div class="b-slider marquee-slider">
    <div class="b-slider__slide">
        <a href="#" class="b-slider__ref">
            <picture class="b-slider__picture">
                <img src="https://cdn.shopify.com/s/files/1/0789/1333/files/Forbes.svg?v=1593719066" class="b-slider__img">
            </picture>
        </a>
    </div>
    <div class="b-slider__slide">
        <a href="#" class="b-slider__ref">
            <picture class="b-slider__picture">
                <img src="https://cdn.shopify.com/s/files/1/0789/1333/files/Nat_Geo.svg?v=1593719066" class="b-slider__img">
            </picture>
        </a>
    </div>
    <div class="b-slider__slide">
        <a href="#" class="b-slider__ref">
            <picture class="b-slider__picture">
                <img src="https://cdn.shopify.com/s/files/1/0789/1333/files/Red_Cross.svg?v=1593719066" class="b-slider__img">
            </picture>
        </a>
    </div>
    <div class="b-slider__slide">
        <a href="#" class="b-slider__ref">
            <picture class="b-slider__picture">
                <img src="https://cdn.shopify.com/s/files/1/0789/1333/files/Discovery_Channel.svg?v=1593719066" class="b-slider__img">
            </picture>
        </a>
    </div>
    <div class="b-slider__slide">
        <a href="#" class="b-slider__ref">
            <picture class="b-slider__picture">
                <img src="https://cdn.shopify.com/s/files/1/0789/1333/files/REI.svg?v=1593719066" class="b-slider__img">
            </picture>
        </a>
    </div>
    <div class="b-slider__slide">
        <a href="#" class="b-slider__ref">
            <picture class="b-slider__picture">
                <img src="https://cdn.shopify.com/s/files/1/0789/1333/files/Fortune.svg?v=1593719066" class="b-slider__img">
            </picture>
        </a>
    </div>
</div>
              
            
!

CSS

              
                body {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  height: 100vh;
}

.b-slider {
  background-color: #f7f7f7;
  overflow-x: hidden;
  min-width: 100%;
  outline: 0;
  &:hover {
    .b-slider__img {
      filter: grayscale(1) contrast(0) blur(1px);  
    }
  }
  &__slide {
    text-align: center;
    width: 30rem;
    height: 8rem;
    display: flex;
    align-items: center;
  }
  &__ref {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    &:hover .b-slider__img {
      filter: unset;
    }
  }
}

@media screen and (max-width: 767px) {
  .b-slider {
    &__slide {
      text-align: center;
      width: 20rem;
      height: 8rem;
      display: flex;
      align-items: center;
    }
  }
}

@media screen and (max-width: 556px) {
  .b-slider {
    &__slide {
      text-align: center;
      width: 15rem;
      height: 8rem;
      display: flex;
      align-items: center;
    }
  }
}
              
            
!

JS

              
                let marqueeSlider = document.querySelector('.marquee-slider');
let marqueeSlide = document.querySelector('.b-slider__ref');
let mainTicker = new Flickity('.marquee-slider', {
  accessibility: true,
  resize: true,
  wrapAround: true,
  prevNextButtons: false,
  pageDots: false,
  percentPosition: true,
  setGallerySize: true,
});

// Set initial position to be 0
mainTicker.x = 0;

// Start the marquee animation
play();

// Main function that 'plays' the marquee.
function play() {
  // Set the decrement of position x
  mainTicker.x -= 1.5;

  // Settle position into the slider
  mainTicker.settle(mainTicker.x);

  // Set the requestId to the local variable
  requestId = window.requestAnimationFrame(play);
}

// Main function to cancel the animation.
function pause() {
  if(requestId) {
    // Cancel the animation
    window.cancelAnimationFrame(requestId)

    // Reset the requestId for the next animation.
    requestId = undefined;
  }
}

// Pause on hover/focus
marqueeSlider.addEventListener('mouseenter', () => pause());

// Unpause on mouse out / defocus
marqueeSlider.addEventListener('mouseleave', () => play());
              
            
!
999px

Console