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


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


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.


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.


                <div id="card">
  <div id="title"></div>


                #card {
  height: 50vmin;
  width: 90vmin;
  background-color: white;
  background-image: url(;
  background-size: cover;
  box-shadow: 0 1rem 3rem rgba(black, 0.2);
  transform-style: preserve-3d;
  &:before, &:after {
    content: '';
    position: absolute;
    display: block;
    height: 2px;
    width: 2px;
    border-radius: 50%;
    background: rgba(white, 0.2);
    filter: blur(1px);
  &:before {
    transform: translateZ(1rem);
    $shadows: ();
    @for $i from 1 through 50 {
      $shadows: append($shadows, random(90) * 1vmin random(50) * 1vmin 0 white, comma);
    box-shadow: $shadows;
  &:after {
    height: 3px;
    width: 3px;
    transform: translateZ(2rem);
    $shadows: ();
    @for $i from 1 through 50 {
      $shadows: append($shadows, random(90) * 1vmin random(50) * 1vmin 0 white, comma);
    box-shadow: $shadows;

body {
  display: flex;
  flex-direction: row;
  justify-content: center;
  align-items: center;
  transform-style: preserve-3d;
  perspective: 1000px;

html, body {
  width: 100%;
  height: 100%;
  margin: 0;
  padding: 0;

html {
  background: linear-gradient(to bottom, #dbe6ed, #cfdde5);

*, *:before, *:after {
  box-sizing: border-box;
  position: relative;


                const docElm = document.documentElement;
const cardElm = document.querySelector('#card');
const titleElm = document.querySelector('#title');

const { clientWidth, clientHeight } = docElm;

// Stream of all mousemove events
const mouseMove$ = Rx.Observable
  .fromEvent(docElm, 'mousemove')
  .map(event => ({ x: event.clientX, y: event.clientY }));

// Stream of all touchmove events
const touchMove$ = Rx.Observable
  .fromEvent(docElm, 'touchmove')
  .map(event => ({
    x: event.touches[0].clientX,
    y: event.touches[0].clientY

// Combination of mousemove and touchmove streams
const move$ = Rx.Observable
  .merge(mouseMove$, touchMove$);

// Stream of requestAnimationFrame ticks
const animationFrame$ = Rx.Observable
  .interval(0, Rx.Scheduler.animationFrame);

// Linear interpolation function
function lerp(start, end) {
  const dx = end.x - start.x;
  const dy = end.y - start.y;
  const rate = 0.05;
  return {
    x: start.x + dx * rate,
    y: start.y + dy * rate,

// Mouse/touch moves linearly interpolated
// on every animation frame
const smoothMove$ = animationFrame$
  .withLatestFrom(move$, (tick, move) => move)

// Apply values to styles
smoothMove$.subscribe(pos => {
  const rotX = (pos.y / clientHeight * -50) + 25;
  const rotY = (pos.x / clientWidth * 50) - 25; = `
    transform: rotateX(${rotX}deg) rotateY(${rotY}deg);