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 CSS

These stylesheets will be added in this order and before the code you write in the CSS editor. You can also add another Pen here, and it will pull the CSS from it. Try typing "font" or "ribbon" below.

Quick-add: + add another resource

Add External JavaScript

These scripts will run in this order and before the code in the JavaScript editor. You can also link to another Pen here, and it will run the JavaScript from it. Also try typing the name of any popular library.

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.

              <h1>Flickity - selectCell with selector, vanilla JS</h1>

<div class="button-group">
  <button class="button" data-selector=".cell1">.cell1</button>
  <button class="button" data-selector=".cell2">.cell2</button>
  <button class="button" data-selector=".cell3">.cell3</button>
  <button class="button" data-selector=".cell4">.cell4</button>
  <button class="button" data-selector=".cell5">.cell5</button>

<div class="carousel">
  <div class="carousel-cell cell1"></div>
  <div class="carousel-cell cell2"></div>
  <div class="carousel-cell cell3"></div>
  <div class="carousel-cell cell4"></div>
  <div class="carousel-cell cell5"></div>

              /* external css: flickity.css */

* { box-sizing: border-box; }

body { font-family: sans-serif; }

.carousel {
  background: #FAFAFA;

.carousel-cell {
  width: 66%;
  height: 200px;
  margin-right: 10px;
  background: #8C8;
  border-radius: 5px;
  counter-increment: carousel-cell;

/* cell number */
.carousel-cell:before {
  display: block;
  text-align: center;
  content: counter(carousel-cell);
  line-height: 200px;
  font-size: 80px;
  color: white;

.button {
  font-size: 22px;

.button-group {
  margin-bottom: 20px;
              // external js: flickity.pkgd.js

var flkty = new Flickity('.carousel');

var buttonGroup = document.querySelector('.button-group');

buttonGroup.addEventListener( 'click', function( event ) {
  // filter for button clicks
  if ( !matchesSelector( event.target, '.button' ) ) {
  var selector = event.target.getAttribute('data-selector');
  flkty.selectCell( selector );

Loading ..................