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.

            
              - 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
            
          
!
            
              @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);
}



            
          
!
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