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 CSS

These stylesheets will be added in this order and before the code you write in the CSS editor. You can also add another Pen here, and it will pull the CSS from it. Try typing "font" or "ribbon" below.

Quick-add: + add another resource

Add External JavaScript

These scripts will run in this order and before the code in the JavaScript editor. You can also link to another Pen here, and it will run the JavaScript from it. Also try typing the name of any popular library.

Quick-add: + add another resource

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
Close

Asset uploading is a PRO feature.

As a PRO member, you can drag-and-drop upload files here to use as resources. Images, Libraries, JSON data... anything you want. You can even edit them anytime, like any other code on CodePen.

Go PRO

Loading ..................

Console