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

              
                #app  
  .Carousel
    .lightbox(
      v-show="lightboxActive" 
      @click.self="lightboxActive=false; currLightboxImg = currImgIdx"
    )
      img(:src="imgList[currLightboxImg].src")
      .prev(@click="goToImg(currLightboxImg-1)")
      .next(@click="goToImg(currLightboxImg+1)")

    img.currImg(
      :src="imgList[currImgIdx].src"
      @click="lightboxActive=true"
    )
    transition-group.CROP(
      :name="transition_name" 
      tag="div"
    )
      .Carousel_chunk(
        v-for="(chunk,i) in arrChunk"
        v-show="currSlide == i"
        :key="i"
      )
        //- :style=`width:${(100/chunkSize).toFixed(1)}%;`
        .chunk_item(
          v-for="(item,j) in chunk"
          :key="j"
          @click="currImgIdx = j+(i*chunkSize)"
          :class="{CURR: item.src == imgList[currImgIdx].src}"
        )
          img(
            :src="item.src"
          )

    .Carousel-controls
      //- button(@click="prev()") « СЮДА
      svg(
        @click="prev", 
        width='48', height='48', viewBox='0 0 24 24', 
        fill='gold', stroke='currentColor', 
        stroke-width='2', stroke-linecap='round', stroke-linejoin='round'
      )
        circle(cx='12', cy='12', r='10')
        polyline(points='12 8 8 12 12 16')
        line(x1='16', y1='12', x2='8', y2='12')

      .Carousel-controls_dot(
        v-for="(dot, i) in arrChunk"
        :class="{CURR : currSlide == i}"
        @click="goToChunk(i)"
      ) {{i+1}}
      //- button(@click="next()") ТУДА »
      svg(
        @click="next", 
        width='48', height='48', viewBox='0 0 24 24', 
        fill='gold', stroke='currentColor', 
        stroke-width='2', stroke-linecap='round', stroke-linejoin='round'
      )
        circle(cx='12', cy='12', r='10')
        polyline(points='12 16 16 12 12 8')
        line(x1='8', y1='12', x2='16', y2='12')
              
            
!

CSS

              
                *
  margin 0
  padding 0
  box-sizing border-box

  
#app
  display flex
  height 100vh
  
.CROP
  height 96px
  overflow hidden
  width 100%
  padding 8px 0
  // background #EEE

.Carousel
  margin auto
  width 480px
  &_chunk
    display flex
    // justify-content center
    justify-content space-between
    align-items center
  .currImg
    cursor pointer

.chunk_item
  // flex 1
  height 80px
  margin 2px
  padding 2px
  border 1px solid transparent
  cursor pointer
  &:hover
    border 1px solid #2196f3  
  &.CURR
    background gold
    outline 2px solid #000
    border-color transparent
  img
    display inline-block
    height 100%

$W = 1.2rem
$H = 1.2rem
.Carousel
  &-controls
    user-select none
    display flex
    justify-content space-between
    align-items center
    &_dot,
    svg
      cursor pointer
    svg:hover
      fill yellow
  &-controls_dot
    border-radius: 50%
    width $W
    line-height $H

    text-align center
    background-color #222 //rgba(#000, .3)
    font-family sans-serif
    font-size .5em
    color #FFF
    &:hover
      // background-color #2196f3
      transform scale(1.4, 1.4)
    &.CURR
      cursor none
      background-color gold//#477dca
      color #000
      font-weight bold
      transform scale(1.4, 1.4)
    
    
    
.slide_next-enter-active,
// .slide_next-leave-active,
.slide_prev-enter-active,
// .slide_prev-leave-active
  transition: transform .3s //cubic-bezier(0.47, 0, 1,-0.96); //ease-out
  // opacity .5

.slide_next-enter,
// .slide_prev-leave-to
  transform: translateX(100%)

// .slide_next-leave-to,
.slide_prev-enter
  transform: translateX(-100%)
  
  
.lightbox
  cursor pointer
  user-select none
  position fixed
  z-index 1
  top: 0;
  left: 0;
  width 100%
  height 100%
  //background //rgba(#000, .7)
  background #616574 url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='80' height='80' viewBox='0 0 10 10' fill='none' stroke-linecap='round' stroke-linejoin='round' stroke='gold'><line x1='4' y1='4' x2='6' y2='6' /><line x1='6' y1='4' x2='4' y2='6' /></svg>") top right no-repeat
  display flex
  img
    cursor default
    margin auto
    
    //width: auto
    max-width: 90%
    max-height: 100%
    
    
.prev
.next
  position absolute
  top 50%

  width 40px
  height 60px
  margin -30px 4% 0

  background #444 url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 10 10' fill='none' stroke-linecap='round' stroke-linejoin='round'><path stroke='gold' d='M6,2 L4,5 L6,8'/></svg>") center / cover no-repeat

  &:hover
    background-color #222
.next
  right 0
  background-image url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 10 10' fill='none' stroke-linecap='round' stroke-linejoin='round'><path stroke='gold' d='M4,2 L6,5 L4,8'/></svg>")
              
            
!

JS

              
                const imgList = Array.from({length:33},(v,i) => ({src: `//raw.githubusercontent.com/codrops/HoverEffectIdeas/master/img/${i+1}.jpg`}))


const vm = new Vue({
  el: "#app",
  data() {
    return {
      chunkSize: 4,
      imgList: imgList,
      currSlide: 0,
      currImgIdx: 15,
      transition_name: "slide_next",
      lightboxActive: false,
      currLightboxImg: 15
    }
  },
  watch: {
    currImgIdx(newVal) {
      this.currLightboxImg = newVal
    }
  },
  computed: {
    arrChunk() {
      return Array
        .from({ length: Math.ceil(this.imgList.length / this.chunkSize) }, (v, i) =>
              this.imgList.slice(i * this.chunkSize, i * this.chunkSize + this.chunkSize)
             );
    }
  },
  methods: {
    prev() {
      this.transition_name = "slide_prev";
      this.currSlide = this.currSlide == 0 ? this.arrChunk.length - 1 : this.currSlide-1;
    },
    next() {
      this.transition_name = "slide_next";
      this.currSlide = this.currSlide == this.arrChunk.length - 1 ? 0 : this.currSlide+1;
    },
    goToImg(n) {
      this.currLightboxImg = n<0 ? this.imgList.length-1 : n%this.imgList.length;
    },
    goToChunk(idx) {
      this.transition_name = (idx < this.currSlide) ? "slide_prev" : "slide_next";
      this.currSlide = idx;
    }
  }
});
              
            
!
999px

Console