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 is required to process package imports. If you need a different preprocessor remove all packages first.

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

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="viewport">

  <div class="search"> <input type="search" placeholder="Search"/></div>
  
<!-- =========== -->
  <div class="card">
    <div class="card-container">
      <div class="card-front">
 
        <header>
          <h1 class="title">Robe of Eyes</h1>
          <div class="menu">
            <div>Attuned</div>
            <div class="icon icon-mark-on"></div>
          </div>
        </header>
  
        <main>
          <div class="pic" style="background-image:url(https://media-waterdeep.cursecdn.com/avatars/thumbnails/7/378/1000/1000/636284763771366253.jpeg);">&nbsp;</div>
          <div class="content">
            <div class="content-inner">
              <p>This robe is adorned with eyelike patterns. While you wear the robe you have unatural perception.</p>
              <p><em>Perception advantage. Darkvision. See&nbsp;ethereal Plane. See&nbsp;invisible</em></p>
            </div>
          </div>
        </main>

        <footer>
          <div class="sub-stats">
            <ul>
              <li>GP 145</li>
              <li>Wondrous Item, rare</li>
            </ul>
          </div>
          <div class="icon icon-flip"></div>
        </footer>

      </div><!--card-front-->
      <div class="card-back">
        <header>??</header>
        <main class="long-content"><p>
This robe is adorned with eyelike patterns. While you wear the robe, you gain the following benefits:</p>

  <ul>
    <li>The robe lets you see in all directions, and you have advantage on Wisdom (Perception) checks that rely on sight.</li>
    <li>You have darkvision out to a range of 120 feet.</li>
    <li>You can see invisible creatures and objects, as well as see into the Ethereal Plane, out to a range of 120 feet.</li>
  </ul>

<p>The eyes on the robe can't be closed or averted. Although you can close or avert your own eyes, you are never considered to be doing so while wearing this robe.</p>

<p>A light spell cast on the robe or a daylight spell cast within 5 feet of the robe causes you to be blinded for 1 minute. At the end of each of your turns, you can make a Constitution saving throw (DC 11 for light or DC 15 for daylight), ending the blindness on a success.</p></main>
        <footer><div class="icon icon-flip"></div></footer>
      </div><!-- card-back -->
    </div>
  </div>
  
<!-- =========== -->
  <div class="card">
    <div class="card-container">
      <div class="card-front">
 
        <header>
          <h1 class="title">Greatsword</h1>
          <div class="menu">
            <div class="">2d6 slashing</div>
            <div class="icon icon-mark-off"></div>
          </div>
        </header>
  
        <main>
          <div class="pic" style="background-image: url(https://media-waterdeep.cursecdn.com/avatars/thumbnails/7/178/315/315/636284725246714619.jpeg)">&nbsp;</div>
          <div class="content">
            <div class="content-inner">
              <p>Proficiency with a greatsword allows you to add your proficiency bonus to the attack roll for any attack you make with it.</p>
            </div>
          </div>
        </main>

        <footer>
          <div class="sub-stats">
            <ul>
              <li>GP 50</li>
              <li>6 lbs</li>
              <li>Heavy, Two-Handed</li>
            </ul>
          </div>
          <div class="icon icon-flip"></div>
        </footer>

      </div><!--card-front-->
      <div class="card-back">
        <header>Header</header>
        <main>Main</main>
        <footer><div class="icon icon-flip"></div></footer>
      </div><!-- card-back -->
    </div>
  </div>
  
<!-- =========== -->
  <div class="card">
    <div class="card-container">
      <div class="card-front" style="background-image:url(https://images.unsplash.com/photo-1577735572110-c1ffd571b4e3?ixlib=rb-1.2.1&ixid=eyJhcHBfaWQiOjEyMDd9&auto=format&fit=crop&w=564&q=80)">
        <header>Card title</header>
        <main>Card content</main>
        <footer>flip</footer>
      </div>
      <div class="card-back">
        <header>Card title</header>
        <main>Card content</main>
        <footer>flip</footer>
      </div>
    </div>
  </div>
  
<!-- =========== -->
  
  <div class="card">
    <div class="card-container">
      <div class="card-front" style="background-image:url(https://images.unsplash.com/photo-1579693207456-a3c037d9a8d4?ixlib=rb-1.2.1&ixid=eyJhcHBfaWQiOjEyMDd9&auto=format&fit=crop&w=634&q=80)">
        <header>Card title</header>
        <main>Card content</main>
        <footer>flip</footer>
      </div>
      <div class="card-back">
        <header>Card title</header>
        <main>Card content</main>
        <footer>flip</footer>
      </div>
    </div>
  </div>
  
<!-- =========== -->
  <div class="card">
    <div class="card-container">
      <div class="card-front">
        <header>Card title</header>
        <main>Card content</main>
        <footer>flip</footer>
      </div>
      <div class="card-back">
        <header>Card title</header>
        <main>Card content</main>
        <footer>flip</footer>
      </div>
    </div>
  </div>
   
<!-- =========== -->
  <div class="card">
    <div class="card-container">
      <div class="card-front">
        <header>Card title</header>
        <main>Card content</main>
        <footer>flip</footer>
      </div>
      <div class="card-back">
        <header>Card title</header>
        <main>Card content</main>
        <footer>flip</footer>
      </div>
    </div>
  </div>
  
<!-- =========== -->
  <div class="card">
    <div class="card-container">
      <div class="card-front">
        <header>Card title</header>
        <main>Card content</main>
        <footer>flip</footer>
      </div>
      <div class="card-back">
        <header>Card title</header>
        <main>Card content</main>
        <footer>flip</footer>
      </div>
    </div>
  </div>
  
<!-- =========== -->
  <div class="card">
    <div class="card-container">
      <div class="card-front">
        <header>Card title</header>
        <main>Card content</main>
         <footer>flip</footer>
      </div>
      <div class="card-back">
        <header>Card title</header>
        <main>Card content</main>
         <footer>flip</footer>
      </div>
    </div>
  </div>
  
<!-- =========== -->
  <div class="card">
    <div class="card-container">
      <div class="card-front">
        <header>Card title</header>
        <main>Card content</main>
        <footer>flip</footer>
      </div>
      <div class="card-back">
        <header>Card title</header>
        <main>Card content</main>
        <footer>flip</footer>
      </div>
    </div>
  </div>
  
<!-- =========== -->
  <div class="card">
    <div class="card-container">
      <div class="card-front">
        <header>Card title</header>
        <main>Card content</main>
        <footer>flip</footer>
      </div>
      <div class="card-back">
        <header>Card title</header>
        <main>Card content</main>
        <footer>flip</footer>
      </div>
    </div>
  </div>
  
<!-- =========== -->
  <div class="card">
    <div class="card-container">
      <div class="card-front">
        <header>Card title</header>
        <main>Card content</main>
        <footer>flip</footer>
      </div>
      <div class="card-back">
        <header>Card title</header>
        <main>Card content</main>
        <footer>flip</footer>
      </div>
    </div>
  </div>
  
<!-- =========== -->
  <div class="card">
    <div class="card-container">
      <div class="card-front">
        <header>Card title</header>
        <main>Card content</main>
        <footer>flip</footer>
      </div>
      <div class="card-back">
        <header>Card title</header>
        <main>Card content</main>
        <footer>flip</footer>
      </div>
    </div>
  </div>
  
<!-- =========== -->
  <div class="card">
    <div class="card-container">
      <div class="card-front">
        <header>Card title</header>
        <main>Card content</main>
        <footer>flip</footer>
      </div>
      <div class="card-back">
        <header>Card title</header>
        <main>Card content</main>
        <footer>flip</footer>
      </div>
    </div>
  </div>
  
</div>

              
            
!

CSS

              
                $speed: 400ms;
$customEase: cubic-bezier(0.000, 0.055, 0.000, 0.995);
$card-color: #f1ede5;
$card-text-color: darken($card-color, 75%);

html, body {
  height:100%;
  margin: 0;
  overscroll-behavior: none;
}
html {
  touch-action: manipulation;
  // https://bit.ly/2viCeII
}

.viewport {
  width:100%;
  height:100%;
  overflow: overlay; //https://stackoverflow.com/q/39253887
  -webkit-overflow-scrolling: touch;
  background:silver;
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
}

.viewport.noscroll {
  overflow: hidden;
}

.card {
  width: calc( 100% - 10px );
  max-width: 420px;
  position: absolute;
  top: 0;
  height: calc( 100vh - 4rem );
  max-height: 620px;
  transform: translateY(0);
  transition: transform $speed $customEase;
  perspective: 1000px;
}

.card-container {
  height:100%;
  position: relative;
  transition: transform $speed ease;
  transform-style: preserve-3d;
}

.card-front,
.card-back {
  height:100%;
  width: 100%;
  position: absolute;
  top: 0;
  border:solid 1px darken($card-color, 15%);
  border-top: solid 1px lighten($card-color, 5%);
  display: flex;
  flex-direction: column;
  -webkit-backface-visibility: hidden;
  border-radius: 0.5rem;
}

.card-front {
  transform: rotateY(0);
  background: white;
  transition: box-shadow 500ms;
  box-shadow: rgba(0,0,0,0.5) 0 -8px 8px -8px;
  background-size: cover;//   temp
}
.card-back {
  transform: rotateY(180deg);
  background: teal;
  box-shadow: rgba(0, 0, 0, 0.5) 0 17px 30px -10px;
}

.card.flip .card-container {
  transform: rotateY(180deg);
}
.openCard .card-front{
  box-shadow: rgba(0, 0, 0, 0.3) 0 17px 30px -10px;
}

.card-front,
.card-back {
  width: 100%;
  height: 100%;
  overflow: hidden;
  
  background: $card-color;
  color: $card-text-color;
  border-radius: 0.5rem;
  
  display: flex;
  flex-direction: column;
  
  h1 {
    font-size: 1.1rem;
    font-style: italic;
  }
  
  header, footer {
    height: 48px;
    overflow: hidden;
  }
  
  header, footer, .menu {
    display: flex;
    justify-content: space-between;
    align-items: center;
  }
  
  header, footer {
    font-size: 0.85em;
    flex-shrink: 0;
  }
  
  .title, 
  .sub-stats {
    padding:0 1rem;
  }
  
  .sub-stats ul {
    list-style: none;
    padding: 0;
    margin: 0;
  }
  
  .sub-stats li {
    display: inline-block;
    margin-right: 0.75rem;
  }
  
  main {
    flex-grow: 1;

    display:flex;
    flex-direction: column;
    align-items: center;
    
    .pic {
      flex-grow: 1;
      width: 100%;

      background-size: contain;
      background-repeat: no-repeat;
      background-position: center center;
      background-color: $card-color;
      background-blend-mode: multiply;
    }

    .content {
      text-align: center;
      width: 75%;
      
      &:before,
      &:after {
        content: '';
        display: block;
        border-top: solid 1px mix($card-color, $card-text-color, 66%);
        width: 20%;
        margin: 1rem auto 0;
      }
      
      &:before {
        margin-bottom: 1.5rem;
      }
      &:after {
        margin-top: 1.5rem;
      }
    }
    
  }
    .long-content {
      padding: 1rem 1rem;
      line-height: 1.5;
      overflow: hidden;
      * { margin: 0; }
      *+* {
        margin-top: 1rem;
      }
    }
}

.flip .long-content {
  overflow: auto;
}


// ================ Search ================

.search {
  padding: 0.5rem;
  position: fixed;
  top:0;
  width:100%;
  max-width: 420px;
  
  input {
    width:100%;
    border-radius:10em;
    border: none;
    background: rgba(255,255,255,0.5);
    -webkit-appearance: none;
    height: 32px;
    font-size: 1rem;
    line-height: 32px;
    text-indent:0.5rem;
    
    &:focus {
      outline:none;
      background: rgba(255,255,255,0.75);
    }
  }
}


// ================ Icons ================

.icon {
  display:block;
  height:3rem;
  width: 3rem;
  text-align: center;
  line-height: 3rem;
  background-repeat: no-repeat;
  background-position: center center;
}

  .icon-flip {
    //https://yoksel.github.io/url-encoder/
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' height='24' viewBox='0 0 24 24' width='24'%3E%3Cpath d='M0 0h24v24H0z' fill='none'/%3E%3Cpath d='M18.4 10.6C16.55 8.99 14.15 8 11.5 8c-4.65 0-8.58 3.03-9.96 7.22L3.9 16c1.05-3.19 4.05-5.5 7.6-5.5 1.95 0 3.73.72 5.12 1.88L13 16h9V7l-3.6 3.6z' fill='%2339301f' /%3E%3C/svg%3E");
  }

.icon-flip-x {
  transform: scaleX(-1);
}

.icon-mark-off {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' height='24' viewBox='0 0 24 24' width='24'%3E%3Cpath d='M17 3H7c-1.1 0-1.99.9-1.99 2L5 21l7-3 7 3V5c0-1.1-.9-2-2-2zm0 15l-5-2.18L7 18V5h10v13z'/%3E%3Cpath d='M0 0h24v24H0z' fill='none'/%3E%3C/svg%3E");
}
.icon-mark-on {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' height='24' viewBox='0 0 24 24' width='24'%3E%3Cpath d='M17 3H7c-1.1 0-1.99.9-1.99 2L5 21l7-3 7 3V5c0-1.1-.9-2-2-2z'/%3E%3Cpath d='M0 0h24v24H0z' fill='none'/%3E%3C/svg%3E");
}

.icon-attune-off {background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' height='24' viewBox='0 0 24 24' width='24'%3E%3Cpath d='M22 9.24l-7.19-.62L12 2 9.19 8.63 2 9.24l5.46 4.73L5.82 21 12 17.27 18.18 21l-1.63-7.03L22 9.24zM12 15.4l-3.76 2.27 1-4.28-3.32-2.88 4.38-.38L12 6.1l1.71 4.04 4.38.38-3.32 2.88 1 4.28L12 15.4z'/%3E%3Cpath d='M0 0h24v24H0z' fill='none'/%3E%3C/svg%3E");}
.icon-attune-on {
background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' height='24' viewBox='0 0 24 24' width='24'%3E%3Cpath d='M0 0h24v24H0z' fill='none'/%3E%3Cpath d='M12 17.27L18.18 21l-1.64-7.03L22 9.24l-7.19-.61L12 2 9.19 8.63 2 9.24l5.46 4.73L5.82 21z'/%3E%3Cpath d='M0 0h24v24H0z' fill='none'/%3E%3C/svg%3E");
}
              
            
!

JS

              
                const offset = 16;
const cardStack = 3;
const viewport = $('.viewport');
const allCards = $( ".card" );


allCards.each(function( index ) {
  index++;
  offsetCalced = index * (offset * 3);
  $(this).css('transform', 'translatey('+ offsetCalced +'px)');
  $(this).data('naturalTop', offsetCalced );
});


$('.card header').click(function(){
  var target = $(this).closest('.card');
  var viewportScroll = viewport.scrollTop();
  var viewportHeight = viewport.outerHeight();
  
  if ( viewport.hasClass('noscroll') ) {
    //Cards are open so do these things:
    $('.viewport').removeClass('noscroll');
    allCards.removeClass('flip').removeClass('openCard');
    allCards.each(function( index ) {
      var targetNaturalY = $(this).data('naturalTop');
      $(this).css('transform', 'translatey('+targetNaturalY+'px)');
    });
    
  } else {
    //Cards are closed so do these things:
    $('.viewport').addClass('noscroll');
    target.css('transform', 'translatey('+ (viewportScroll + 5) +'px)');
    target.addClass('openCard');
    total = viewportScroll+viewportHeight;
    
    x = cardStack;    
    allCards.not(target).each(function(i){
      if (i < cardStack){
        $(this).css('transform', 'translatey('+ (total - ( x*offset )) +'px)');
      } else {
        $(this).css('transform', 'translatey('+ (total + offset) +'px)');
      }
      i++;
      x--;
    });
  }

});


$('footer').click(function(){
  $(this).closest('.card').toggleClass('flip');
});
              
            
!
999px

Console