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

              
                - index = -1
- pagecount = 5
- checked = false
%div.settings
%span.size-span Choose book size:
- (1..4).each do |i|
  - if i == 2
    - checked = true
  %input.size-input{:id => "size-#{i}", :type => "radio", :name => "book-size", :checked => checked}
  %label.size-label{:for => "size-#{i}"} #{i}
  - checked = false
%form.book
  - (1..pagecount).each do |i|
    %input.checkbox{:id => "checkbox-#{i}", :type => "checkbox"}
  - (1..pagecount).each do |i|
    %label.next-label{:for => "checkbox-#{i}", :class => "next-label-#{i}"}
    %label.prev-label{:for => "checkbox-#{i}", :class => "prev-label-#{i}"}
    - index = index + 1
    %div.page.front{:class => "page-#{i}"}
      %span.pagenum #{index}
      %span.fold
    - index = index + 1
    %div.page.back{:class => "page-#{i}"}
      %span.pagenum #{index}
      %span.fold
  %input{:type => "reset", :value => "Start again"}
              
            
!

CSS

              
                $item-count: 5;
$bg-color: #6599FF;
$cover-color: #5C4033;
$page-color: #fff;

html {
  background-color: $bg-color;
  color: #000;
  font-family: Verdana, Geneva, sans-serif;
  font-size: 0.875em;
  padding: 0;
  margin: 0;
}

body {
  padding: 0;
  margin: 0;
}

#size-1:checked ~ .book {
  font-size: 0.8em;
}

#size-3:checked ~ .book {
  font-size: 1.2em;
}

#size-4:checked ~ .book {
  font-size: 1.4em;
}

.settings {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 25px;
  line-height: 25px;
  background-color: rgba(0, 0, 0, 0.6);
  color: #fff;
}

.size-span, .size-label {
  float: left;
  position: relative;
  line-height: 25px;
}

.size-input {
  display: none;
}

.size-label {
  float: left;
  text-align: center;
  position: relative;
  margin-left: 0.5em;
  border-radius: 50%;
}

.size-input:checked + label {
  color: #c00;
}

.book {
  margin: 0 auto;
  display: block;
  font-size: 1em;
  /* standard paper aspect ratio */
  width: 29.286em;
  height: 21.214em;
  position: relative;
  top: 50px;
  -webkit-perspective: 1000px;
  perspective: 1000px;
  -webkit-transition: width 0.5s ease-out, height 0.5s ease-out;
  -moz-transition: width 0.5s ease-out, height 0.5s ease-out;
  -ms-transition: width 0.5s ease-out, height 0.5s ease-out;
  -o-transition: width 0.5s ease-out, height 0.5s ease-out;
  transition: width 0.5s ease-out, height 0.5s ease-out;
}

input[type="reset"] {
  width: 30%;
  line-height: 20px;
  position: absolute;
  left: 50%;
  bottom: -50px;
  margin-left: -15%;
  background: none;
  border: 2px solid #fff;
  color: #fff;
  font-weight: bold;
  border-radius: 20px;
}

.page {
  width: 50%;
  height: 100%;
  position: absolute;
  top: 0;
  background: $page-color;
  background-image: linear-gradient(#eee .1em, transparent .1em);
background-size: 100% 1.2em;
  -webkit-transition: -webkit-transform ease-out 1s;
  -moz-transition: -moz-transform ease-out 1s;
  -o-transition: -o-transform ease-out 1s;
  transition: transform ease-out 1s;
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
  -webkit-animation: turn-back 1s;
  animation: turn-back 1s;
}

.page-1.front {
  -webkit-animation: init 1s;
  animation: init 1s;
  background: $cover-color;
  
  &:before {
    content: 'CSS3 for dummies (hover and click the fold to turn page)';
    color: #fff;
    display: block;
    padding: 10%;
    text-align: center;
    font-weight: bold;
  }
  
  .pagenum {
    display: none;
  }
}

.page-#{$item-count}.back {
  background: $cover-color;
  
  .pagenum {
    display: none;
  }
}

.page-#{$item-count}.front {
  .fold {
    background: $cover-color;
  }
}

.page-1.back {
  .fold {
    background: $cover-color;
  }
}

.page.front {
  -webkit-border-radius: 0 3px 3px 0;
  -moz-border-radius: 0 3px 3px 0;
  border-radius: 0 3px 3px 0;
  right: 0;
  -webkit-transform-origin: left center;
  -moz-transform-origin: left center;
  transform-origin: left center;
  box-shadow: inset 7px 0 9px -7px rgba(0,0,0,0.4);
  
  .fold {
    right: 0;
    left: auto;
    border-radius:3px 0 0 0;
  }
  
  &:hover .fold {
      border-width: 40px 40px 0 0;
  }
}

.page.back {
  -webkit-border-radius: 3px 0 0 3px;
  -moz-border-radius: 3px 0 0 3px;
  border-radius: 3px 0 0 3px;
  -webkit-transform: rotateY(180deg);
  -ms-transform: rotateY(180deg);
  transform: rotateY(180deg);
  left: 0;
  -webkit-transform-origin: right center;
  -moz-transform-origin: right center;
  transform-origin: right center;
  box-shadow: inset -7px 0 9px -7px rgba(0,0,0,0.4);
  
  .fold {
    right: auto;
    left: 0;
    border-radius: 0 3px 0 0;
    border-width: 0;
  }
}

.fold {
  width: 0;
  height: 0;
  position: absolute;
  bottom: 0;
  top: auto;
  border-width: 0;
  border-style: solid;
  background: #eee;
  display:block;
  border-color:transparent $bg-color transparent $bg-color;

  -webkit-transition: border-width 0.2s ease-out;
  -moz-transition: border-width 0.2s ease-out;
  -ms-transition: border-width 0.2s ease-out;
  -o-transition: border-width 0.2s ease-out;
  transition: border-width 0.2s ease-out;
}

.page .pagenum {
  position: absolute;
  bottom: 0.893em;
  left: 0;
  right: 0;
  text-align: center;
  font-size: 0.8em;
}

input[type="checkbox"] {
  display: none;
}

.next-label, .prev-label {
  position: absolute;
  bottom: 0;
  z-index: $item-count * 2 + 3;
  -webkit-transition: all ease-out;
  -moz-transition: all ease-out;
  -o-transition: all ease-out;
  transition: all ease-out;
}

.next-label {
  width: 40px; 
  height: 40px;
  right: 0;
  
  &:hover ~ .page.front .fold {
      border-width: 40px 40px 0 0;
  }
}

.prev-label {
  left: 0;
  pointer-events: none;
  width: 40px; 
  height: 40px;
}

@for $i from 1 through $item-count {
  
  $prev: $i - 1;
  $next: $i + 1;
  $duration: 1 - $i / 20;
  
  #checkbox-#{$i}:checked { 
    ~ .page-#{$i}.front {
      -webkit-transform: rotateY(-180deg);
      -ms-transform: rotateY(-180deg);
      transform: rotateY(-180deg);
      
      .fold {
        border-width: 0;
      }
    }
    
    ~ .page-#{$i}.back {
      -webkit-transform: rotateY(0deg);
      -ms-transform: rotateY(0deg);
      transform: rotateY(0deg);
      
      &:hover .fold {
        border-width: 40px 0 0 40px;
      }
    }
    
    ~ .prev-label-#{$i}:hover ~ .page.back .fold {
      border-width: 40px 0 0 40px;
    }
  }

  .page-#{$i} {
    z-index: $item-count - $prev;
    -webkit-transition-duration: #{$duration}s;
    -moz-transition-duration: #{$duration}s;
    -o-transition-duration: #{$duration}s;
    transition-duration: #{$duration}s;
  }

  .next-label-#{$i} {
    z-index: $item-count - $prev +1;
  }

  #checkbox-#{$i}:checked ~ .next-label-#{$i} {
    display: none;
    pointer-events: none;
  }

  #checkbox-#{$i}:checked ~ .prev-label-#{$i} {
    -webkit-animation: make-visible 2s forwards;
    animation: make-visible 2s forwards;
    pointer-events: auto;
  }
  
  #checkbox-#{$i}:checked ~ .next-label-#{$next} {
    -webkit-animation: make-visible 2s forwards;
    animation: make-visible 2s forwards;
    pointer-events: auto;
  }
  
  #checkbox-#{$i}:checked ~ .prev-label-#{$prev} {
    display: none;
  }

  #checkbox-#{$i}:checked ~ .page-#{$i} {
    z-index: $item-count + $i;
    -webkit-transition-duration: 1s;
    -moz-transition-duration: 1s;
    -o-transition-duration: 1s;
    transition-duration: 1s;
    -webkit-animation: turn 1s;
    animation: turn 1s;
  }

  .next-label-#{$i}:checked {
    z-index: $item-count + $i;
  }
 
}

@keyframes turn {
  from {
    z-index: $item-count * 2 + 1;
  }
  to {
    z-index: $item-count * 2 + 1;
  }
}

@-webkit-keyframes turn {
  from {
    z-index: $item-count * 2 + 1;
  }
  to {
    z-index: $item-count * 2 + 1;
  }
}

@keyframes turn-back {
  from {
    z-index: $item-count * 2 + 1;
  }
  to {
    z-index: $item-count * 2 + 1;
  }
}

@-webkit-keyframes turn-back {
  from {
    z-index: $item-count * 2 + 1;
  }
  to {
    z-index: $item-count * 2 + 1;
  }
}

@keyframes init {
  from {
    z-index: $item-count * 2 + 2;
  }
  to {
    z-index: $item-count * 2 + 2;
  }
}

@-webkit-keyframes init {
  from {
    z-index: $item-count * 2 + 2;
  }
  to {
    z-index: $item-count * 2 + 2;
  }
}
              
            
!

JS

              
                
              
            
!
999px

Console