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 class="demo">  
  <div class="demo__description">
    Pull down on the cards
  </div>
  <div class="demo__phone">
    <div class="demo__screen-wrapper">
      <div class="demo__screen">
        <div class="demo__indicator demo__indicator--time">16:22</div>
        <div class="demo__indicator demo__indicator--signal">
          <i class="fa fa-signal"></i>
        </div>
        <div class="demo__indicator demo__indicator--battery">
          <i class="fa fa-battery"></i>
        </div>
        <div class="demo__controls">
          <div class="demo__arrow">
            <i class="fa fa-chevron-left"></i>
          </div>
          <div class="demo__caption">Inbox</div>
        </div>

        <div class="demo__card demo__card demo__card--notched">
          <div class="demo__card-frontside">
            <div class="demo__card-type">PAYMENT</div>
            <div class="demo__card-body">
              <div class="demo__card-picture demo__card-picture--apple"></div>
              <div class="demo__card-info">
                <div class="demo__card-caption">Apple store</div>
                <div class="demo__card-description">12 Manchester st., London</div>
              </div>
              <div class="demo__card-money">-$999</div>
            </div>
            <div class="demo__card-bottom">
              <div class="demo__card-button">View balance</div>
              <div class="demo__card-time">5m ago</div>
            </div>
          </div>
          <div class="demo__card-backside">
            <div class="demo__card-release">
              release
            </div>
          </div>
        </div>

        <div class="demo__card demo__card--regular">
          <div class="demo__card-frontside">
            <div class="demo__card-type">PAYMENT</div>
            <div class="demo__card-body">
              <div class="demo__card-picture demo__card-picture--starbucks"></div>
              <div class="demo__card-info">
                <div class="demo__card-caption">Starbucks</div>
                <div class="demo__card-description">100 Washington st, New York</div>
              </div>
              <div class="demo__card-money">-$8</div>
            </div>
            <div class="demo__card-bottom">
              <div class="demo__card-button">View balance</div>
              <div class="demo__card-time">2h ago</div>
            </div>
          </div>          
        </div>
        <div class="demo__card demo__card--regular">
          <div class="demo__card-frontside">
            <div class="demo__card-type">CASH WITHDRAWAL</div>
            <div class="demo__card-body">
              <div class="demo__card-picture demo__card-picture--citi"></div>
              <div class="demo__card-info">
                <div class="demo__card-caption">Citi bank</div>
                <div class="demo__card-description">52 Philadelphia st, San Francisco</div>
              </div>
              <div class="demo__card-money">-$150</div>
            </div>
            <div class="demo__card-bottom">
              <div class="demo__card-button">View balance</div>
              <div class="demo__card-time">2h ago</div>
            </div>
          </div>          
        </div>

        <div class="demo__card demo__card--regular">
          <div class="demo__card-frontside">
            <div class="demo__card-type">INCOMING PAYMENT</div>
            <div class="demo__card-body">
              <div class="demo__card-picture demo__card-picture--paypal"></div>
              <div class="demo__card-info">
                <div class="demo__card-caption">PayPal</div>
                <div class="demo__card-description"></div>
              </div>
              <div class="demo__card-money">$40</div>
            </div>
            <div class="demo__card-bottom">
              <div class="demo__card-button">View balance</div>
              <div class="demo__card-time">yesterday at 14:02</div>
            </div>
          </div>
        </div>
      </div>
    </div>
    <div class="demo__notch"></div>
  </div>  
</div>
              
            
!

CSS

              
                $resX: 1125px;
$resY: 2436px;
$notch-height: 90px;
$notch-width: 627px;
$notch-border-radius: 60px;
$bezels: 48px;
$screen-border-radius: 120px;
$phone-border-radius: 160px;
$scale: 4;
$indicator-top-margin: 10px;
$margins: 36px;

$iphone-color: #120d30;
$notch-color: $iphone-color;
$screen-background: linear-gradient(#4a3972, #5e4a9d);
$indicators-color: white;
$background:  #FECA45;

*, *:before, *:after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

.demo {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 20px;
  min-height: 100vh;
  
  font-family: 'Open Sans', sans-serif;
  
  background-color: $background;
  
  &__description {
    font-size: 80px / $scale;
    padding-bottom: 20px;
  }
  
  &__phone {
    position: relative;
    
    width: ($resX + $bezels * 2) / $scale;
    height: ($resY + $bezels * 2) / $scale;    
    padding-top: 1px;   
    
    background-color: $iphone-color;
    
    border-radius: $phone-border-radius / $scale;    
  }
  
  &__notch {
    position: absolute;
    top: $bezels / $scale;
    left: (($resX - $notch-width) / 2 + $bezels) / $scale;
    
    height: $notch-height / $scale;
    width: $notch-width / $scale;
    
    background-color: $notch-color;
    
    border-radius: 0 0 $notch-border-radius / $scale $notch-border-radius / $scale;
  }
  
  &__screen {
    position: relative;
    
    height: $resY / $scale;
    width: $resX / $scale;
    
    padding-top: 100px / $scale;    
      
    background: $screen-background;
    
    border-radius: $screen-border-radius / $scale;
    cursor: grab;
    user-select: none;
    perspective: 700px;
  }
  
  &__screen-wrapper {  
    position: relative;    
    
    height: $resY / $scale;
    width: $resX / $scale;
    margin-top: $bezels / $scale - 1px;
    margin-left: $bezels / $scale;    
    overflow: hidden;
    
    border-radius: $screen-border-radius / $scale;
  }
  
  &__indicator {
    position: absolute;
    top: $indicator-top-margin / $scale;
    font-size: 54px / $scale;
    color: $indicators-color;
    
    &--time {
      left: 75px / $scale;
    }
    
    &--signal {
      right: 180px / $scale;
    }  
    
    &--battery {
      font-size: 57px / $scale;
      right: 66px / $scale;
    }
  }
  
  &__controls {
    position: relative;    
    display: flex;
    justify-content: center;
    
    padding: 25px / $scale 0;
    
    font-size: 75px / $scale;
    
    color: $indicators-color;
  }
  
  &__arrow {
    position: absolute;
    left: 50px / $scale;
  }  
  
  &__card {
    position: relative;
    
    margin: $margins / $scale;
    height: 570px / $scale;
    width: calc(100% - #{$margins / $scale * 2});
    
    font-size: 70px / $scale;    
    
    border-radius: 20px / $scale;
    transform-style: preserve-3d;
    
    &--notched {
      position: absolute;
      top: 0;
      
      transform: rotateX(180deg) scale(0.6) translateY(700px / $scale);
    }
    
    &--processing {
      position: absolute;
      top: 0;
      
      transform: translateY(250px / $scale);     
    }
  }
  
  &__card-frontside {
    position: absolute;
    top: 0;
    
    width: 100%;
    height: 100%;
    padding-top: $margins / $scale;
    padding-bottom: $margins / 2 / $scale;
    
    background-color: white;
    
    border-radius: 20px / $scale;
    backface-visibility: hidden;
  }
  
  
  &__card-backside {
    display: flex;
    justify-content: center;
    align-items: flex-end;
    position: absolute;
    top: 0;
    
    width: 100%;
    height: 100%;
    
    color: white;
    background: linear-gradient($notch-color 50%, lighten($notch-color, 10%));
    
    border-radius: $notch-border-radius / $scale / 0.6;
    transform: rotateX(180deg);
    backface-visibility: hidden;
  }
  
  &__card-release {
    padding: 20px / $scale;
    opacity: 0;
    
    transition: opacity 0.2s ease;
  }
  
  &__card-type {
    padding-left: $margins * 2 / $scale;   
   
    font-size: 50px / $scale;
    
    color: #aaa;
  }
 
  &__card-body {
    display: flex;
    align-items: center;  
    padding-left: $margins * 2 / $scale;
    padding-right: $margins * 2 / $scale;
    padding-top: $margins / $scale;
    padding-bottom: $margins / $scale;
  }
  
  &__card-picture {
    width: 200px / $scale;
    height: 200px / $scale;
    flex-shrink: 0;
    
    border-radius: 50%;
    background-size: contain;
    background-repeat: no-repeat;
    background-position: center;
    
    &--starbucks {
      background-image: url(https://kiyutink.github.io/logos/starbucks.svg);
    }
    
    &--citi {
      background-image: url(https://kiyutink.github.io/logos/citi.png);
      
    }
    
    &--paypal {
      background-image: url(https://kiyutink.github.io/logos/paypal.svg);
    }
    
    &--apple {
      background-image: url(https://kiyutink.github.io/logos/apple.png);
    }
  }
  
  &__card-info {
    width: 70%;
    
    margin-left: $margins / $scale;
    margin-right: $margins / $scale;
  }
  
  &__card-caption {
    width: 100%;    
    
    font-weight: 700;
  }
  
  &__card-description {
    min-height: 150px / $scale;
    
    font-size: 55px / $scale;
  }
  
  &__card-money {
    font-size: 70px / $scale;
    font-weight: 700;
  }
  
  &__card-bottom {
    display: flex;
    justify-content: space-between;
    border-top: 1px solid #ddd;
  }
  
  &__card-button {    
    padding-top: $margins / 2 / $scale;
    padding-left: $margins * 2 / $scale;
    
    color: #6b6281;
    
    cursor: pointer;
  }
  
  &__card-time {
    padding-top: $margins / $scale;
    padding-right: $margins * 2 / $scale;
    
    font-size: 50px / $scale;
    
    color: #ddd;
  }
}

.animation {
  transition: transform 0.5s cubic-bezier(.55,.26,.12,1.19);
}

.short-animation {
  transition: transform .2s ease;
}

              
            
!

JS

              
                $(document).ready(function() { 
  const SCALE = 4;
  const ANIMATION_DURATION = 500;
  const QUICK_ANIMATION_DURATION = 200;
  const DRAG_LIMIT = 375;
  
  let initialMouseY;
  let lastTranslateValue = 0;
  let diff = 0;
  let busy = false;
  let cardsCreated = 0;
  let $notched = $('.demo__card--notched');
  let $controls = $('.demo__controls');
  let $cards = $('.demo__card');
  let $regularCards = $('.demo__card--regular');
  let $timeIndicator = $('.demo__indicator--time');  
  
  const codepenCard = {
    type: 'LINK',
    imageUrl: 'https://kiyutink.github.io/logos/codepen.png',
    caption: '<a class="demo__profile-link" href="https://codepen.io/kiyutink/" target="_blank">My codepen</a>',
    description: 'Check out my other pens',
    time: 'just now'
  }
  
  const twitterCard = {
    type: 'LINK',
    imageUrl: 'https://kiyutink.github.io/logos/twitter.jpg',
    caption: '<a class="demo__profile-link" href="https://twitter.com/kiyutin_k" target="_blank">My twitter</a>',
    description: 'Follow me',
    time: 'just now'
  }
  
  const dribbbleCard = {
    type: 'LINK',
    imageUrl: 'https://kiyutink.github.io/logos/dribbble.png',
    caption: '<a class="demo__profile-link" href="https://dribbble.com/shots/4089014-Pull-To-Refresh-iPhone-X" target="_blank">Dribble shot</a>',
    description: 'By Saptarshi Prakash',
    time: 'just now'
  }
  
  setCurrentTime();
  setInterval(setCurrentTime, 60 * 1000);  
  
  function setCurrentTime() {
    const curDate = new Date();
    let hours = curDate.getHours() + '';
    if (hours.length <= 1)
      hours = 0 + hours;
    let minutes = curDate.getMinutes() + '';
    if (minutes.length <= 1)
      minutes = 0 + minutes;
    $timeIndicator.text(`${hours}:${minutes}`);
  }
  
  
  $('.demo__phone').on('mousedown touchstart', '.demo__screen', e => {
    e.preventDefault();
    if (busy) return;
    initialMouseY = e.clientY || e.touches[0].clientY;
    
    $(document).on('mousemove touchmove', scrollCards);
  });
  
  function scrollCards(e) {
    diff = (e.clientY || e.touches[0].clientY) - initialMouseY;
    if (diff < 0) 
      return;
     
    if (diff < DRAG_LIMIT / SCALE) 
      $notched.find('.demo__card-release').css('opacity', 0);    
      
    if (diff > DRAG_LIMIT / SCALE) {
      diff = DRAG_LIMIT / SCALE;
      $notched.find('.demo__card-release').css('opacity', 0.6);
    }
    
    $notched.css('transform', `scale(0.6) rotateX(180deg) translateY(${700 / SCALE - diff}px)`)
    $regularCards.css('transform', `translateY(${diff + lastTranslateValue}px)`);
  }
  
  function makeCard(cardDetails) {    
    return `
      <div class="demo__card demo__card demo__card--notched">
        <div class="demo__card-frontside">
          <div class="demo__card-type">${cardDetails.type}</div>
          <div class="demo__card-body">
            <div class="demo__card-picture" style='background-image: url(${cardDetails.imageUrl});'></div>
            <div class="demo__card-info">
              <div class="demo__card-caption">${cardDetails.caption}</div>
              <div class="demo__card-description">${cardDetails.description}</div>
            </div>            
          </div>
          <div class="demo__card-bottom">
              <div class="demo__card-button">View balance</div>
              <div class="demo__card-time">${cardDetails.time}</div>
          </div>
        </div>
        <div class="demo__card-backside">
            <div class="demo__card-release">
              release
            </div>
        </div>
      </div>
`}
  
  
  $(window).on('mouseup touchend', () => {
    $(document).off('mousemove touchmove', scrollCards);
    lastTranslateValue = diff + lastTranslateValue;
    if (lastTranslateValue >= DRAG_LIMIT / SCALE) {
      busy = true;
      const animatedCard = $('.demo__card--notched');
      $cards.addClass('animation');
      setTimeout(() => {
        $cards.removeClass('animation');
        animatedCard.addClass('demo__card--regular').removeClass('demo__card--processing');
        $regularCards = $('.demo__card--regular');
        $regularCards.css('transform', 'none');
        busy = false;
      }, ANIMATION_DURATION);
      
      $regularCards.css('transform', `translateY(${605 / SCALE}px)`);
      $notched.css('transform', '').removeClass('demo__card--notched').addClass('demo__card--processing');
      
      if (cardsCreated >= 4)
        cardsCreated = 0;
      
      switch (cardsCreated) {
        case 0:
          $controls.after(makeCard(codepenCard));
          break;
        case 1:
          $controls.after(makeCard(twitterCard));
          break;
        case 2:
          $controls.after(makeCard(dribbbleCard));
          break;
        case 3:
          $controls.after(makeCard({
            type: 'PAYMENT',
            caption: 'Kirill Kiyutin',
            imageUrl: 'https://kiyutink.github.io/profile-pic.jpg',
            description: 'Moscow, Russia',            
            time: 'just now'
          }));
          break;
      }
      
      cardsCreated ++;
      
      $notched = $('.demo__card--notched');
      $cards = $('.demo__card');
    }
    
    else {
      if (busy)
        return;
      $cards.addClass('short-animation');
      setTimeout(() => {        
        $cards.removeClass('short-animation');
      }, QUICK_ANIMATION_DURATION);
      $notched.css('transform', `rotateX(180deg) scale(0.6) translateY(${700 / SCALE}px)`);
      $regularCards.css('transform', 'none');      
    }
    diff = 0;
    lastTranslateValue = 0;
  });  
});
              
            
!
999px

Console