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. You can use the CSS from another Pen by using it's URL and the proper URL extention.

+ 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

              
                - 100.times do
  .blind

.front
  %img{:src => "https://s3-us-west-2.amazonaws.com/s.cdpn.io/46992/bear.png", :class => "bear figures"}
  %img{:src => "https://s3-us-west-2.amazonaws.com/s.cdpn.io/46992/sheep.png", :class => "sheep figures"}
  %img{:src => "https://s3-us-west-2.amazonaws.com/s.cdpn.io/46992/monster.png", :class => "monster figures"}
  %img{:src => "https://s3-us-west-2.amazonaws.com/s.cdpn.io/46992/bat.png", :class => "bat figures"}
  %img{:src => "https://s3-us-west-2.amazonaws.com/s.cdpn.io/46992/carp.png", :class => "carp figures"}
  %img{:src => "https://s3-us-west-2.amazonaws.com/s.cdpn.io/46992/dinosaure.png", :class => "dinosaure figures"}
  %img{:src => "https://s3-us-west-2.amazonaws.com/s.cdpn.io/46992/wardrobe.png", :class => "wardrobe figures"}
  %img{:src => "https://s3-us-west-2.amazonaws.com/s.cdpn.io/46992/bed.png", :class => "bed figures"}
  %img{:src => "https://s3-us-west-2.amazonaws.com/s.cdpn.io/46992/table.png", :class => "table figures"} 
  .back
              
            
!

CSS

              
                @import "compass/css3";

@import url(https://fonts.googleapis.com/css?family=Open+Sans);

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

html, body {
  width:100%;
  height:100%;
}

body {
  font-family: 'Open Sans', sans-serif;
  transform-style:preserve-3d;
}

/////////////////////////////
// basic 3d setup and styling
/////////////////////////////

.front, .back {
  position:relative;
  width:100vw;
  height:100vh;
  transform-style:preserve-3d;
  
  &:before, &:after {
    content:'';
    position:absolute;
    background-image:url('https://s3-us-west-2.amazonaws.com/s.cdpn.io/46992/dirtywall.jpg');
    background-size:cover;
    background-repeat:no-repeat;
    background-blend-mode: multiply;
  }
}

.front {
  z-index:2;
  perspective:400px;
  perspective-origin: 50% 50%;
  transition:perspective-origin 0.6s;
  
  &:before, &:after {
    top:0;
    right:0;
    width:100vw;
    height:100vh;
  }

  &:before {
    background-color:#957141;
    transform-origin:0% 50%;
    transform:rotateY(90deg);
  }

  &:after {
    background-color:#866e18;
    transform-origin:100% 50%;
    transform:rotateY(-90deg);
  }
}

.back {
  z-index:1;
  background-color:#b9a08d;
  background-image:url('https://s3-us-west-2.amazonaws.com/s.cdpn.io/46992/dirtywall.jpg');
  background-size:cover;
  background-blend-mode: multiply;
  transform:translateZ(-100vw);
  
  &:before, &:after {
    right:0;
    left:0;
    height:100vw;
  }

  &:before {
    top:0;
    background-color:#bdcbcb;
    transform-origin:50% 0%;
    transform:rotateX(90deg);
  }

  &:after {
    bottom:0;
    background-color:#887a68;
    background-image:url('https://s3-us-west-2.amazonaws.com/s.cdpn.io/46992/woodenfloor.jpg');
    transform-origin:50% 100%;
    transform:rotateX(-90deg);
  }
}


/////////////////////////////
// Hover Indicators == <div class="blind"></div>
/////////////////////////////

// number of Hover Indicators == divs with class .blind
// up to 100 elements are fine
$blinds:100; 

// square root of $blinds
// in this case == 10
// FYI: sqrt($number); is a math helper function
// to use this function you need the sass add-on compass
$sqrt-root:sqrt($blinds);
$magic-num:100 / $sqrt-root;

// basic styling for each .blind div
.blind {
  position:absolute;
  width:$magic-num * 1%;
  height:$magic-num * 1%;
  z-index:5;
  background-color:white;
  opacity:0;
  // uncomment following two lines to see the grid
  // opacity:0.3;
  // box-shadow:inset 0 0 0 1px red;
}

// This two nested @for loops are used to build 
// a nth-number of rows containing an equal number of elements
// in our case there're 10 rows that contain 10 elements
// first row top:0%  --  second row top:10% -- ...
// first element left:0% -- second element left:10% -- ...
// □□□□□□□□□□
// □□□□□□□□□□
// ...
// it also handels the change of the perspective origin, 
// that is set on the .front element
@for $i from 1 through $sqrt-root {
  @for $e from 1 through $sqrt-root {
    $current:($i * $sqrt-root) - $sqrt-root;
    .blind:nth-child(#{$current + $e}) {
      top:($i - 1) * ($magic-num * 1%);
      left:($e - 1) * ($magic-num * 1%);
    }
    .blind:nth-child( #{$current + $e} ):hover ~ .front {
      perspective-origin:(($e - 1) * ($magic-num * 1%)) (($i - 1) * ($magic-num * 1%));
    }
  }
}

// that's all. Hopefully it's well enough documented
// if you have any questions, use the comment section on the details page

// the following lines are just positioning the interior elements

/////////////////////////////
// interior elements
/////////////////////////////

.figures {
  position:absolute;
  display:block;
  height:auto;
}

.bear {
  left:30%;
  bottom:0;
  width:50%;
  height:auto;
  z-index:2;
  transform:translateZ(-70vw);
}

.sheep {
  left:0;
  bottom:0;
  width:30%;
  z-index:2;
  transform:translateZ(-55vw);
}

.monster {
  left:5%;
  bottom:0;
  width:12%;
  z-index:2;
  transform:translateZ(-3vw);
}

.bat {
  left:15%;
  bottom:0;
  width:10%;
  z-index:2;
  transform:translateZ(-4vw);
}

.carp {
  left:22%;
  bottom:0%;
  width:7%;
  z-index:2;
  transform:translateZ(-2vw);
}

.dinosaure {
  left:28%;
  bottom:0;
  width:15%;
  z-index:2;
  transform:translateZ(-4vw);
}

.wardrobe {
  right:5%;
  bottom:0;
  width:15%;
  z-index:2;
  transform:translateZ(-7vw);
}

.bed {
  right:24%;
  bottom:2%;
  width:23%;
  z-index:2;
  transform:translateZ(-2vw);
}

.table {
  right:21%;
  bottom:2%;
  width:20%;
  z-index:2;
  transform:translateZ(-13vw);
}



              
            
!

JS

              
                
              
            
!
999px

Console