Pen Settings

HTML

CSS

CSS Base

Vendor Prefixing

Add External Stylesheets/Pens

Any URLs added here will be added as <link>s in order, and before the CSS in the editor. You can use the CSS from another Pen by using its URL and the proper URL extension.

+ 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

Auto Save

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="container">
  <div id="background" class="page-background">
    <div style="width: 100%; text-align: center;">
      <p>-- END --</p>
      <p>Thanks for reading.</p>
    </div>
  </div>
  
  <div id="page3" data-page-number="3" class="cssanimation page" onClick="hidePageByNumber(3)">
    Third page.
  </div>
  <div id="page2" data-page-number="2" class="cssanimation page" onClick="hidePageByNumber(2)">
    Second page.
  </div>
  <div id="page1" data-page-number="1" class="cssanimation page" onClick="hidePageByNumber(1)">
    <p>Dear Friends,</p>
    <p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Praesent euismod porta tempor. Donec pulvinar turpis nec velit pellentesque quis rhoncus sapien facilisis. Mauris quis massa dui, rhoncus viverra quam. Nulla tempus, augue ut consectetur facilisis, arcu elit pellentesque arcu, sed rutrum orci turpis pulvinar augue. Donec eget arcu mauris. Vestibulum tristique consequat lacus eget laoreet. Integer sed nisl sed nibh pulvinar ornare quis nec quam. Aenean rhoncus ligula ut lectus placerat a commodo quam vulputate. In eu metus turpis.</p>
    <p>Cum sociis natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus. Phasellus facilisis erat in nibh auctor at aliquet velit vestibulum. Curabitur turpis diam, malesuada eu consequat eget, ultricies sed nunc. Aenean sed odio massa. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Vestibulum ornare vulputate congue. Quisque leo metus, condimentum nec molestie et, egestas luctus libero.</p>
    <p>Mauris porta odio augue. Nam turpis dui, volutpat id feugiat vitae, sagittis a justo. Nam iaculis aliquet erat non varius. Suspendisse justo arcu, tincidunt sed auctor sit amet, fermentum id turpis. Suspendisse sed enim quis lorem vestibulum fermentum a ut nulla.</p>
    <p>Nullam tincidunt elit quis nibh blandit interdum. Duis ullamcorper pellentesque pretium. Nulla facilisi. Morbi semper nisi et justo varius non fermentum metus ornare. Proin vehicula, mi vel volutpat accumsan, libero lacus euismod massa, id feugiat velit enim nec ligula. Aliquam ipsum est, volutpat aliquam tincidunt id, sagittis et velit. Nunc vitae massa vel dui facilisis consectetur vel id sem.</p>

    <p>Aenean pulvinar, lacus ultrices euismod viverra, nulla diam interdum ligula, id mollis mi erat quis lectus. Morbi quis felis ut turpis condimentum dictum porttitor id mauris. Nam non tincidunt mauris. Donec viverra eleifend pharetra. Nulla eu ipsum et elit consectetur rutrum. Integer lorem purus, ultricies ac laoreet quis, feugiat vel dolor. Donec eu turpis neque. Nullam molestie sapien eu nibh semper sed convallis est pretium.</p>
  </div>
  
</div>
              
            
!

CSS

              
                body {
  background: linear-gradient(#ccc, #fff);
  
  font: 14px sans-serif;
  
  padding: 20px;
  min-height: 700px;
}

.container
{
  position: relative;
  
  margin: 26px auto 0;
  max-width: 600px;
  width: 80%;
}



.page,
.page-background {
  position: relative;
  background: #fff;
  box-shadow: 0 0 10px rgba(0,0,0,0.3);
  
  min-height: 600px;
  padding: 24px; 
  width: 90%; /* 100% throws the div out over the right-side of .container */
}

.page-background 
{
  z-index: 1;
  position: absolute;
}

.page
{
  z-index: 2;
  position: absolute;
  cursor: grab;
}



.page-background:before, 
.page-background:after {
  content: "";
  height: 98%;
  position: absolute;
  width: 100%;
  z-index: -1;
}
.page-background:before {
  background: #fafafa;
  box-shadow: 0 0 8px rgba(0,0,0,0.2);
  left: -5px;
  top: 4px;
  transform: rotate(-2.5deg);
}
.page-background:after {
  background: #f6f6f6;
  box-shadow: 0 0 3px rgba(0,0,0,0.2);
  right: -3px;
  top: 1px;
  transform: rotate(1.4deg);
}



.cssanimation, .cssanimation span {
    animation-duration: 1s;
    animation-fill-mode: both;
}

.cssanimation span { display: inline-block }

.fadeOutLeft { animation-name: fadeOutLeft }
@keyframes fadeOutLeft {
    from { opacity: 1 }
    to {
        opacity: 0;
        transform: translateX(-100%);
    }
}
              
            
!

JS

              
                var pageStack = {
  //TODO: Implement. 
  visiblePageNumber: 1, // The currently visible page. 
  
  allPages: [1, 2, 3]   // Ordered list of all pages.
};





/*
* Remove/hide the selected page from view for a given element ID.
*
* @param string pageID - ID of the element representing 
*                        the page to hide.
*/
function hidePageById(pageId)
{
  var pageElement = document.getElementById(pageId);
  pageElement.classList.add("fadeOutLeft");  
}





/*
* Remove/hide the selected page from view for a 
* given data-page-number.
*
* @param int pageNumber - value of a data-page-number attribute
*                            for the page to hide.
*/
function hidePageByNumber(pageNumber)
{
  var pageElement = document.querySelector("[data-page-number='" + pageNumber + "']");
  pageElement.classList.add("fadeOutLeft");
  
  pageStack.visiblePageNumber = getNextPageNumber(pageNumber);
  
  console.log("Hiding page: " + pageNumber + ". Next page is: " + pageStack.visiblePageNumber);
}





/*
* Return the page in the stack after the specified page.
*
* @param int currentPage - Number of the current page.
*                          Looks for the page after this page.
*
* @return int Number of the next page.
*             0 (zero) if not found or currentPage is last page.
*/
function getNextPageNumber(currentPage)
{
  let nextPageNumber = 0;
  
  for (let i = 0; i < pageStack.allPages.length; i++)
  {
    let pageNumber = pageStack.allPages[i];
    if (pageNumber == currentPage)
    {
      if (i == pageStack.allPages.length - 1)
      {
        // Current page is the final page.
        nextPageNumber = 0;
      }
      else
      {
        // Get the next page
        nextPageNumber = pageStack.allPages[i + 1];
        break;
      }
    }
  }
  
  return nextPageNumber;
}
              
            
!
999px

Console