Pen Settings

HTML

CSS

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

JavaScript

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

Behavior

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.

HTML Settings

Here you can Sed posuere consectetur est at lobortis. Donec ullamcorper nulla non metus auctor fringilla. Maecenas sed diam eget risus varius blandit sit amet non magna. Donec id elit non mi porta gravida at eget metus. Praesent commodo cursus magna, vel scelerisque nisl consectetur et.

HTML

              
                <div id="app" class="media-display">
  <button @click="prev" class="button prev">Prev</button>
  <button @click="shuffle" class="button shuffle">Shuffle</button>
  <button @click="next" class="button next">Next</button>
  
  <transition-group name="flip-list" class="media-gallery">
    <figure 
            class="media-post" 
            v-for="(image,i) in images" 
            :key="image" 
            @click="shift(image)"
            :style="{ 
                    '--i': i, 
                    '--flip-delay': images.length - i 
                    }">
      <img :src="image" width="400" height="400" />
      <figcaption>{{i+1}}</figcaption>
    </figure>
  </transition-group>
</div>
              
            
!

CSS

              
                .flip-list-move {
  transition: -webkit-transform 0.5s cubic-bezier(0.5, 0, 0.5, 1);
  transition: transform 0.5s cubic-bezier(0.5, 0, 0.5, 1);
  transition: transform 0.5s cubic-bezier(0.5, 0, 0.5, 1), -webkit-transform 0.5s cubic-bezier(0.5, 0, 0.5, 1);
  transition-delay: calc(var(--flip-delay) * 50ms);
}

/* ---------------------------------- */
html {
  font-size: 62.5%;
  height: 100%;
  background: #2c3e50;
}

body {
  min-height: 100%;
  display: grid;
  place-items: center;
  text-align: center;
}

.button {
  border: none;
  color: #FFF;
  background: #42b983;
  -webkit-appearance: none;
     -moz-appearance: none;
          appearance: none;
  font: inherit;
  font-size: 1.25rem;
  padding: .5em 1em;
  border-radius: .3em;
  cursor: pointer;
}

.shuffle {
  color: #2c3e50;
  background: #FFF;
}

.media-gallery {
  display: block;
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  grid-gap: 2rem;
  margin: 1rem auto;
  width: 80vmin;
  position: relative;
}

.media-post {
  display: inline-block;
  padding: 1vmin;
  border-radius: 2vmin;
  box-shadow: 0 10px 5px rgba(0, 0, 0, 0.2);
  margin: 0;
  background: #FFF;
  position: relative;
  cursor: pointer;
}
.media-post img {
  border-radius: 1vmin;
  display: block;
  max-width: 100%;
  height: auto;
}
.media-post figcaption {
  color: #FFF;
  position: absolute;
  top: 0;
  left: 0;
  font-weight: bold;
  padding: 1rem 1.5rem;
  z-index: 2;
  font-size: 2rem;
  text-shadow: 0 1px 2px #000;
}
              
            
!

JS

              
                new Vue({

  // Mount Vue instance to DOM with `el`
  // https://vuejs.org/v2/api/#el
  el: '#app',

  // State with data
  // http://vuejs.org/v2/guide/instance.html#Data-and-Methods
  data() {
    return {
      images: [
        'https://source.unsplash.com/ZVKr8wADhpc/400x400',
        'https://source.unsplash.com/zNU3ErDAbAw/400x400',
        'https://source.unsplash.com/x-rqS-3Qi10/400x400',
        'https://source.unsplash.com/tR-hmR1ZGmE/400x400',
        'https://source.unsplash.com/N8ldzkCZ7yY/400x400',
        'https://source.unsplash.com/KZa4fREZoKk/400x400',
        'https://source.unsplash.com/gR_AgAcP7jI/400x400',
        'https://source.unsplash.com/aG6ByqGXiXg/400x400',
        'https://source.unsplash.com/Y3quvtI_LJE/400x400'
      ] 
    };

  },

  // Method Event Handlers
  // https://vuejs.org/v2/guide/events.html#Method-Event-Handlers
  methods: {

    // Move the last item to the beginning of the array
    prev() {
      this.images.unshift(this.images.pop());
    },

    // Randomize the order of items
    shuffle() {
      this.images = this.images.
      sort(() => 0.5 - Math.random()).
      sort(() => 0.5 - Math.random());
    },

    // Move the first item to the end of the array
    next() {
      this.images.push(this.images.shift());
    },

    shift(image) {
      this.images.splice(this.images.indexOf(image), 1);
      this.images.unshift(image);
    } 
  } 
});
              
            
!
999px

Console