123

Pen Settings

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

You're using npm packages, so we've auto-selected Babel for you here, which we require to process imports and make it all work. If you need to use a different JavaScript preprocessor, remove the packages in the npm tab.

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

Use npm Packages

We can make npm packages available for you to use in your JavaScript. We use webpack to prepare them and make them available to import. We'll also process your JavaScript with Babel.

⚠️ This feature can only be used by logged in users.

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.

HTML Settings

Here you can Sed posuere consectetur est at lobortis. Donec ullamcorper nulla non metus auctor fringilla. Maecenas sed diam eget risus varius blandit sit amet non magna. Donec id elit non mi porta gravida at eget metus. Praesent commodo cursus magna, vel scelerisque nisl consectetur et.

            
              <div class="container">
  <div class="folder">
   <div class="paper">
      <h1>Sample paper</h1>
      <p>Lorem ipsum dolor sit amets, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet. Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet.</p>
      <p>Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet. Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet.</p>
      <p>Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet. Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet.</p>
    </div>
    <div class="cover">
      <div class="title">Don't open</div>
    </div>
  </div>
</div>
            
          
!
            
              @import "compass/css3";

$color-folder: #fab62f;

// Inverts a location so that top gets bottom and left gets right etc.
@function invert-location($location) {
  @if $location == left {
    @return right;  
  }
  @elseif $location == right {
    @return left;  
  }
  @elseif $location == top {
    @return bottom;  
  }
  @elseif $location == bottom {
    @return top;  
  }
}

// Gets the start position left on horizontal and top on vertical
@function position-start($location) {
  @if $location == top or $location == bottom {
    @return left;
  }
  @else {
    @return top;
  }
}

// Gets the end position right on horizontal and bottom on vertical
@function position-end($location) {
  @if $location == top or $location == bottom {
    @return right;
  }
  @else {
    @return bottom;
  }
}

// Decides if size needs to be height or width based on horizontal or vertical 
@function size-property($location) {
  @if $location == top or $location == bottom {
    @return width;
  }
  @else {
    @return height;
  }
}

/* 
   Generates the negative triangle as part of a offset with :before and :after

   $location: Where you want the negative triangle [top, right, bottom, left]

   $position: In percentage where the negative triangle should be placed. With 50% the cut out triangle is in the center.

   $size: How much will the surface be extruded in order to cut out the triangle. Can be any valid size (px, em, rem, % etc.)

   $color: The color of the extruded part where the triangle gets cut out
*/
@mixin negative-css-triangle($location: top, $position: 50%, $size: 30px, $color: black) {
  &:before, &:after {
    box-sizing: border-box;
    content: "";
    display: block;
    position: absolute;
    #{$location}: -$size * 2;
    border: $size solid transparent;
  }
  
  &:before {
    #{position-start($location)}: 0;
    #{size-property($location)}: $position;
    border-#{position-start($location)}: none;   
    border-#{invert-location($location)}-color: $color;
  }
      
  &:after {
    #{position-end($location)}: 0;
    #{size-property($location)}: 100% - $position;
    border-#{position-end($location)}: none;
    border-#{invert-location($location)}-color: $color;
  }  
}

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

html, body {
  height: 100%;
  width: 100%;
  background-color: shade($color-folder, 60%);
}

.container {
  position: relative;
  width: 100%;
  height: 100%;
        
  > .folder {
    width: 220px;
    height: 180px;
    left: calc(50% - 110px);
    top: calc(70% - 90px);
    position: absolute;
    
    > .cover {
      cursor: pointer;
      position: absolute;
      width: 100%;
      height: 100%;
      background-color: $color-folder; 
      
      @include border-radius(0 0 10px 10px);
      @include box-shadow(5px 5px rgba(0, 0, 0, 0.2));
      
      @include negative-css-triangle(top, 50%, 50px, $color-folder);
      
      > .title {
        position: absolute;
        padding: 1em;
        font-family: Arial, Helvetica, sans-serif;
        text-transform: uppercase;
        font-weight: bold;
        text-align: center;
        font-size: 2.5em;
        color: rgba(0, 0, 0, 0.1);
        @include user-select(none);
        
        @include transform(rotate(20deg));
      }
    }
    
    > .paper {
      opacity: 1;
      position: absolute;
      overflow: hidden;
      width: 200px;
      height: 200px;      
      top: calc(50% - 150px);
      left: calc(50% - 100px);
      
      transition: top 0.5s, opacity 0.4s;
      
      font-family: Verdana, Tahoma, sans-serif;
      font-size: 0.1em;
      padding: 1em;
      color: shade($color-folder, 60%);
      background-color: tint($color-folder, 60%);
      
      @include box-shadow(10px 10px rgba(0, 0, 0, 0.2));
      @include border-radius(5px);
    }
    
    &:hover {
      > .paper {
        top: calc(50% - 200px);
      }
    }
    
    &.opened {
      > .paper {
        top: calc(-500px);
        opacity: 0;
      }
    }
  }
  
}
            
          
!
            
              $(document).on('click', '.folder', function() {
  $(this).toggleClass('opened');
});
            
          
!
999px
🕑 One or more of the npm packages you are using needs to be built. You're the first person to ever need it! We're building it right now and your preview will start updating again when it's ready.

Console