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.

            
              div(class='card')
  div(class='products')
    div(class='product active'
        product-id='1'
        product-color='#D18B49')
      div(class='thumbnail')
        img(src='https://s3-us-west-2.amazonaws.com/s.cdpn.io/169963/Stag.svg')
      h1(class='title') The Magnificent Stag
      p(class='description') Fusce dapibus, tellus ac cursus commodo, tortor mauris condimentum nibh, ut fermentum massa justo sit amet risus.
    div(class='product'
        product-id='2'
        product-color='#542F13')
      div(class='thumbnail')
        img(src='https://s3-us-west-2.amazonaws.com/s.cdpn.io/169963/Bear.svg')
      h1(class='title') The Courageous Bear
      p(class='description') Fusce dapibus, tellus ac cursus commodo, tortor mauris condimentum nibh, ut fermentum massa justo sit amet risus.
    div(class='product'
        product-id='3'
        product-color='#A5AAAE')
      div(class='thumbnail')
        img(src='https://s3-us-west-2.amazonaws.com/s.cdpn.io/169963/Mouse.svg')
      h1(class='title') The Sneaky Mouse
      p(class='description') Fusce dapibus, tellus ac cursus commodo, tortor mauris condimentum nibh, ut fermentum massa justo sit amet risus.
    div(class='product'
        product-id='4'
        product-color='#ED8D1F')
      div(class='thumbnail')
        img(src='https://s3-us-west-2.amazonaws.com/s.cdpn.io/169963/Fox.svg')
      h1(class='title') The Cunning Fox
      p(class='description') Fusce dapibus, tellus ac cursus commodo, tortor mauris condimentum nibh, ut fermentum massa justo sit amet risus.
    div(class='product'
        product-id='5'
        product-color='#C4C8CB')
      div(class='thumbnail')
        img(src='https://s3-us-west-2.amazonaws.com/s.cdpn.io/169963/Rabbit.svg')
      h1(class='title') The Jumpy Rabbit
      p(class='description') Fusce dapibus, tellus ac cursus commodo, tortor mauris condimentum nibh, ut fermentum massa justo sit amet risus.
  div(class='footer')
    a(class='btn'
      id='prev'
      href='#'
      ripple=''
      ripple-color='#666666') Prev
    a(class='btn'
      id='next'
      href='#'
      ripple=''
      ripple-color='#666666') Next

            
          
!
            
              // Duration
$duration: 0.5s;

// Font Family
$body-font: "Roboto";

// Font Weights
$thin: 100;
$light: 300;
$regular: 400;
$semibold: 500;
$bold: 700;
$ultra: 800;

// Base Font
/* $base-background: #00CC99; */
$base-background: #D18B49;
$base-font-family: $body-font, sans-serif;
$base-font-size: 14px;
$base-font-weight: $regular;
$base-line-height: 1.6em;

// Colors
$black: #000000;
$dark-gray: rgba($black, 0.8);
$gray: rgba($black, 0.6);
$light-gray: rgba($black, 0.4);
$lighter-gray: rgba($black, 0.2);
$white: #FFFFFF;
$accent: #4285F4;
$primary: #2F313A;
$secondary: #F4B142;

// Card Settings
$max-width: 400px;
$max-height: null;
$gutters: 24px;

// Elevation
@mixin elevation($level) {
  @if $level == 1 {
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.12), 0 1px 2px rgba(0, 0, 0, 0.24);
  }

  @else if $level == 2 {
    box-shadow: 0 3px 6px rgba(0, 0, 0, 0.16), 0 3px 6px rgba(0, 0, 0, 0.23);
  }

  @else if $level == 3 {
    box-shadow: 0 10px 20px rgba(0, 0, 0, 0.19), 0 6px 6px rgba(0, 0, 0, 0.23);
  }

  @else if $level == 4 {
    box-shadow: 0 14px 28px rgba(0, 0, 0, 0.25), 0 10px 10px rgba(0, 0, 0, 0.22);
  }

  @else if $level == 5 {
    box-shadow: 0 19px 38px rgba(0, 0, 0, 0.3), 0 15px 12px rgba(0, 0, 0, 0.22);
  }
}

body {
  background: $base-background;
  color: $gray;
  font-family: $base-font-family;
  font-size: $base-font-size;
  line-height: $base-line-height;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  transition: $duration ease;
}

// Button
.btn {
  border-radius: 2px;
  padding: ($gutters / 3) ($gutters / 2);
  color: #D18B49;
  font-size: 14px;
  font-weight: $semibold;
  text-decoration: none;
  text-transform: uppercase;
  transition: $duration ease;
}

// Card
.card {
  background: $white;
  max-width: $max-width;
  min-height: $max-height;
  margin: 100px auto;
  border-radius: 12px;
  @include elevation(3);
  box-sizing: border-box;
  padding: ($gutters * 2);
  text-align: center;
}

// Products
.products {
  position: relative;
  overflow: hidden;
  transition: $duration ease;
}

// Product
.product {
  position: absolute;
  top: 0;
  left: 0;
  opacity: 0;
  visibility: hidden;
  transition: $duration ease;
  
  &.active {
    opacity: 1;
    visibility: visible;
  }
}

// Thumbnail
.thumbnail {
  margin: 0 0 ($gutters * 2);
}

// Title
.title {
  margin: 0 0 ($gutters / 2);
  color: #D18B49;
  font-size: 24px;
  transition: $duration ease;
}

// Description
.description {
  margin: 0 0 ($gutters * 2);
}

// Footer
.footer {
  display: flex;
  flex-direction: row;
  justify-content: space-between;
  margin: 0 (-$gutters / 2) (-$gutters / 2);
}

// Ripple
[ripple] {
  z-index: 1;
  position: relative;
  overflow: hidden;

  .ripple {
    position: absolute;
    background: $white;
    width: 60px;
    height: 60px;
    border-radius: 100%;
    transform: scale(0);
    animation: ripple 2s;
  }
}

@keyframes ripple {
  0% {
    transform: scale(0);
    opacity: 0.2;
  }

  100% {
    transform: scale(20);
    opacity: 0;
  }
}
            
          
!
            
              $(document).ready(function() {
  var getProductHeight = $('.product.active').height();

  $('.products').css({
    height: getProductHeight
  });

  function calcProductHeight() {
    getProductHeight = $('.product.active').height();

    $('.products').css({
      height: getProductHeight
    });
  }

  function animateContentColor() {
    var getProductColor = $('.product.active').attr('product-color');

    $('body').css({
      background: getProductColor
    });

    $('.title').css({
      color: getProductColor
    });

    $('.btn').css({
      color: getProductColor
    });
  }

  var productItem = $('.product'),
    productCurrentItem = productItem.filter('.active');

  $('#next').on('click', function(e) {
    e.preventDefault();

    var nextItem = productCurrentItem.next();

    productCurrentItem.removeClass('active');

    if (nextItem.length) {

      productCurrentItem = nextItem.addClass('active');
    } else {
      productCurrentItem = productItem.first().addClass('active');
    }

    calcProductHeight();
    animateContentColor();
  });

  $('#prev').on('click', function(e) {
    e.preventDefault();

    var prevItem = productCurrentItem.prev();

    productCurrentItem.removeClass('active');

    if (prevItem.length) {
      productCurrentItem = prevItem.addClass('active');
    } else {
      productCurrentItem = productItem.last().addClass('active');
    }

    calcProductHeight();
    animateContentColor();
  });

  // Ripple
  $('[ripple]').on('click', function(e) {
    var rippleDiv = $('<div class="ripple" />'),
      rippleSize = 60,
      rippleOffset = $(this).offset(),
      rippleY = e.pageY - rippleOffset.top,
      rippleX = e.pageX - rippleOffset.left,
      ripple = $('.ripple');

    rippleDiv.css({
      top: rippleY - (rippleSize / 2),
      left: rippleX - (rippleSize / 2),
      background: $(this).attr("ripple-color")
    }).appendTo($(this));

    window.setTimeout(function() {
      rippleDiv.remove();
    }, 1900);
  });
});
            
          
!
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