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

You're using npm packages, so we've auto-selected Babel for you here, which we require to process imports and make it all work. If you need to use a different JavaScript preprocessor, remove the packages in the npm tab.

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

Use npm Packages

We can make npm packages available for you to use in your JavaScript. We use webpack to prepare them and make them available to import. We'll also process your JavaScript with Babel.

⚠️ This feature can only be used by logged in users.

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.

            
              .heading
  h1 Custom Carousel
  h6 ( click slides or press left & right arrow keys )
  .me
  a(href="https://github.com/cmdeveloped" target="_blank")
    i(class='fab fa-github')
  a(href="https://twitter.com/collinscode_" target="_blank")
    i(class='fab fa-twitter')
  a(href="https://codepen.io/collinscode" target="_blank")
    i(class='fab fa-codepen')
  a(href="https://linkedin.com/in/cmdeveloped" target="_blank")
    i(class='fab fa-linkedin')

.container
  - for(var x = 0; x < 9; x++)
    .ui-card

            
          
!
            
              flexbox(a, b)
  display flex
  align-items a
  justify-content b
  
gradient(a, b, c)
  background b
  background linear-gradient(a, b, c)
  
color1 = #2E5266
color2 = #6E8898
color3 = #9FB1BC
color4 = #D3D0CB

html
  min-height 100vh
  flexbox(center, center)
  gradient(to bottom, #ECE9E6, #FFF)
  body
    width 100%
    flexbox(center, center)
    flex-direction column
    font-family 'Quicksand', sans-serif
    overflow-x hidden
    position relative
    top -2.5rem
    .heading
      text-align center
      color color1
      margin-bottom 3rem
      h1
        margin-bottom 0
      h6
        margin 0
      p
        margin 0
      a
        color color1
        display inline-block
        .fab
          margin-right 0.5rem
          font-size 1.5rem
          padding 0.5rem
          margin-top 0.5rem

.container
  flexbox(center, center)
  position relative
  .ui-card
    height 20rem
    width 12rem
    position relative
    z-index 1
    transform scale(0.6) translateY(-2rem)
    opacity 0
    cursor pointer
    pointer-events none
    gradient(to top, color1, color2)
    transition 1s
    &:after
      content ''
      position absolute
      height 2px
      width 100%
      border-radius 100%
      background-color rgba(0,0,0,0.3)
      bottom -5rem
      filter blur(4px)
    for val, i in (1..10)
      &:nth-child({i})
        &:before
          content '' + i + ''
          position absolute
          top 50%
          left 50%
          transform translateX(-50%) translateY(-50%)
          font-size 3rem
          font-weight 300
          color white
  .ui-card.active
    z-index 3
    transform scale(1) translateY(0) translateX(0)
    opacity 1
    pointer-events auto
    transition 1s
  .ui-card.prev, .ui-card.next
    z-index 2
    transform scale(0.8) translateY(-1rem) translateX(0)
    opacity 0.6
    pointer-events auto
    transition 1s
            
          
!
            
              $num = $('.ui-card').length;
$even = $num / 2;
$odd = ($num + 1) / 2;

if ($num % 2 == 0) {
  $('.ui-card:nth-child(' + $even + ')').addClass('active');
  $('.ui-card:nth-child(' + $even + ')').prev().addClass('prev');
  $('.ui-card:nth-child(' + $even + ')').next().addClass('next');
} else {
  $('.ui-card:nth-child(' + $odd + ')').addClass('active');
  $('.ui-card:nth-child(' + $odd + ')').prev().addClass('prev');
  $('.ui-card:nth-child(' + $odd + ')').next().addClass('next');
}

$('.ui-card').click(function() {
  $slide = $('.active').width();
  console.log($('.active').position().left);
  
  if ($(this).hasClass('next')) {
    $('.container').stop(false, true).animate({left: '-=' + $slide});
  } else if ($(this).hasClass('prev')) {
    $('.container').stop(false, true).animate({left: '+=' + $slide});
  }
  
  $(this).removeClass('prev next');
  $(this).siblings().removeClass('prev active next');
  
  $(this).addClass('active');
  $(this).prev().addClass('prev');
  $(this).next().addClass('next');
});


// Keyboard nav
$('html body').keydown(function(e) {
  if (e.keyCode == 37) { // left
    $('.active').prev().trigger('click');
  }
  else if (e.keyCode == 39) { // right
    $('.active').next().trigger('click');
  }
});
            
          
!
999px
🕑 One or more of the npm packages you are using needs to be built. You're the first person to ever need it! We're building it right now and your preview will start updating again when it's ready.
Loading ..................

Console