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

              
                img(src="http://labs.serkan.io/images/body.gif" width="40%" class="preview")

div.stack.orbit(style="-webkit-transform: rotateX(-12deg) rotateY(203deg);")
  - for (var i = 1; i <= 41; ++i)
    div(class="item i"+i)
  <div class="plate"></div>
              
            
!

CSS

              
                @import compass

html, body
  height: 100%
  width: 100%
  
body
  background: #000
  +perspective(1100px)
  +user-select(none)
  display: flex
  justify-content: center
  align-items: center
    

$slices: "XlY4oI1" "JAkPgJw" "ux30KuP" "OMMQi7I" "l9yEBaB" "vx2k3z5" "jDQ5uo7" "EZlP7Ao" "P1Hp2ad" "Kxik3AW" "VxMyKPD" "5AbInS4" "wtLXklv" "xEcQzaJ" "N2FdE4h" "hKQfsOk" "jtKeIhw" "tS4MogT" "eEKMdR8" "S1fvRLI" "pRK6OlY" "Q7SWzwe" "EIxG1zU" "fMiS3Ft" "82bpuLK" "aSDAhGS" "DStVN4Q" "Q7Dh4rt" "CHotNQa" "MAC4Bv1" "fAsfWKi" "t8GvYLl" "PVmDAMX" "ClUdEeK" "idcwHZu" "3r1RODG" "6d9VgGi" "ppADkWO" "zIxKVXv" "RvT32mC" "JfBsWvH"
  
.stack  
  width: 250px
  height: 144px
  font-size: 110%
  position: relative

  .plate
    height: 700px
    width: 250px
    border-radius: 1em
    border: 1px solid #ccc
    background-color: #81807e
    background-image: url(http://labs.serkan.io/images/slate.jpg)
    background-size: 940px
    transform: rotateX(90deg) translateZ(214px)
  
  .item
    top: 0
    left: 0
    height: 144px
    width: 250px
    position: absolute
    opacity: 0.8
    //border: 5px solid rgba(200,0,0,0.5)
    //border-radius: 12em 12em 6em 6em
    +transform-style(preserve-3d)
    +background-size(250px)

  @for $i from 1 through length($slices)
    $slice: nth($slices, $i)
    $x: $i - 20
    .i#{$i}
      +transform(translateZ(#{$x}em))
      +background-image(url(http://labs.serkan.io/images/#{$slice}.png))

.preview
  opacity: 0.5
  position: absolute
  top: 5px
  right: 5px
  
  
.orbit
  +transform-style(preserve-3d)
  cursor: move

              
            
!

JS

              
                function orbit(el) {
    el = el || document.querySelector('.orbit');

    // for rotation values stored in CSS use this method instead
    // https://css-tricks.com/get-value-of-css-rotation-through-javascript/
    var getRotateValues = function (el) {
        var vals = { X: 0, Y: 0, Z: 0 };
        var reg = /rotate(.)\((\-?\d+)/gim;
        ((el.getAttribute('style') || "").match(reg) || []).forEach(function (e) {
            vals[e.replace(reg, '$1')] = Number(e.replace(reg, '$2'));
        });
        vals.Y *= -1;
        return vals;
    };

    el.addEventListener('mousedown', function (e) {
        var sx = e.clientX;
        var sy = e.clientY;
        var rot = getRotateValues(el);

        var drag = function (e) {
            var x = e.clientX,
                y = e.clientY;

            el.style.transform = `rotateX(${(rot.X + (sy - y))}deg) rotateY(${((rot.Y + (sx - x)) * -1)}deg)`;
        };

        var end = function () {
            document.removeEventListener('mousemove', drag);
            document.removeEventListener('mouseup', end);
        };

        document.addEventListener('mousemove', drag);
        document.addEventListener('mouseup', end);
    });
}

orbit();
              
            
!
999px

Console