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 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

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

              
                <div id="app">
  <button @click="change">Change</button>
  
  <img-slider :count="list.length" :interval="3000">
    <div v-for="img in list" class="slider">
      <a>
        <img :src="img">
      </a>
    </div>
  </img-slider>
</div>
              
            
!

CSS

              
                #app
  width 484px
  height 242px
img
  width 484px
  height 242px
.slider-wrapper
  position relative
  overflow-x hidden
  ::after
    content ''
    display block
    clear both
  .sliders
    width 99999999px
    transition all .5s
    .slider
      float left
  ul.slider-nav
    position absolute
    right 1rem
    bottom 1rem
    list-style none
    li
      float left
      margin 0 3px
      .circle
        display block
        width 10px
        height @width
        border 1px solid #ddd
        border-radius 50%
        background transparent
        &.active
          background #fb83ac
          border-color #fb83ac
              
            
!

JS

              
                Vue.component('img-slider', {
  template: '<div><div class="slider-wrapper"><div class="sliders clearfix" v-el:sliders><slot></slot></div><ul class="slider-nav"><li v-for="n in count"><span class="circle" :class="{\'active\': n === current}"></span></li></ul></div></div>',
  props: ['count', 'interval'],
  data: function() {
    return {
      current: 0
    };
  },
  ready: function() {
    var that = this;
    var $sliders = this.$els.sliders;
    var goto = function goto(index) {
      if (index === 'next') {
        that.current++;
      } else if (index === 'prev') {
        that.current--;
      } else {
        that.current = parseInt(index);
      }
      that.current = (that.current) % that.count;
      $sliders.style.marginLeft = '-' + (that.current * 100) + '%';
    };
    $sliders.style.width = (this.count * 100) + '%';
    setInterval(function() {
      goto('next');
    }, this.interval);
  }
});
new Vue({
  el: '#app',
  data: {
      list: ['http://image.iqing.in/recommend/613890e9-3e5d-4acd-afae-003201e1d86d.jpg-cover', 'http://image.iqing.in/recommend/11576c83-d543-46e9-9725-89125bd066c2.jpg-cover', 'http://image.iqing.in/recommend/21bd4d0d-19cb-44a5-8946-8ddfc7326ee2.jpg-cover', 'http://image.iqing.in/recommend/d5d1f8e2-e785-4ace-9a90-618d4820056a.jpg-cover']
  },
  methods: {
    change: function () {
      this.list = ['http://image.iqing.in/recommend/d5d1f8e2-e785-4ace-9a90-618d4820056a.jpg-cover','http://image.iqing.in/recommend/11576c83-d543-46e9-9725-89125bd066c2.jpg-cover' ]
    }
  }
});
              
            
!
999px

Console