cssAudio - Activefile-genericCSS - ActiveGeneric - ActiveHTML - ActiveImage - ActiveJS - ActiveSVG - ActiveText - Activefile-genericVideo - ActiveLovehtmlicon-new-collectionicon-personicon-teamlog-outoctocatpop-outspinnerstartv

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.

            
              .container
  .wrapper
    .balloon
    .clouds
      %svg.cloud__obj{:height => "300", :viewbox => "0 0 600 200", :width => "600"}
        %defs
          %path#cloud{:d => "M497.6,128.9c4.1-9.9,6.4-20.8,6.4-32.2c0-46.3-37.5-83.8-83.8-83.8c-21.1,0-40.3,7.8-55,20.6\n\t\t\t\tc-14.7-12.8-33.9-20.6-55-20.6c-46.2,0-83.7,37.4-83.7,83.6c-5.3-1-10.7-1.6-16.3-1.6c-46.3,0-83.8,37.5-83.8,83.8\n\t\t\t\ts37.5,83.8,83.8,83.8c21.1,0,40.3-7.8,55-20.6c14.7,12.8,33.9,20.6,55,20.6s40.3-7.8,55-20.6c14.7,12.8,33.9,20.6,55,20.6\n\t\t\t\tc46.3,0,83.8-37.5,83.8-83.8C514,160.1,507.9,142.9,497.6,128.9z", :fill => "#fff", :stroke => "#fff", "stroke-width" => "10px"}
      %svg.clouds__cloud.clouds__cloud-1
        %use{"xlink:href" => "#cloud"}
      %svg.clouds__cloud.clouds__cloud-2
        %use{"xlink:href" => "#cloud"}
      %svg.clouds__cloud.clouds__cloud-3
        %use{"xlink:href" => "#cloud"}
    .horizon
    .sun
    .cordilheira
    .valley
      .tree
      .tree
      .tree
      .tree
      .tree
      .tree
      .valley__back
        .tree.tree--red
        .tree.tree--red
        .tree.tree--red
        .tree.tree--red
        %svg{:height => "153px", :version => "1.1", :viewbox => "0 0 219 153", :width => "219px", :xmlns => "http://www.w3.org/2000/svg", "xmlns:xlink" => "http://www.w3.org/1999/xlink"}
          %defs
          %g#Page-1{:fill => "none", "fill-rule" => "evenodd", :stroke => "none", "stroke-width" => "1"}
            %path#Path-2{:d => "M0,101.204176 L1.04882812,85.7627697 C20.2753906,64.5557384 41.3066406,53.0765718 64.1425781,51.3252697 C98.3964844,48.6983166 101.634766,48.5850353 118.871094,35.9580822 C136.107422,23.3311291 148.498047,-7.23332405 217.904297,1.5674572 C217.904297,42.3031343 218.098307,92.2764416 218.486328,151.487379 L3.203125,152.719801 L0,101.204176 Z", :fill => "#B12129"}
      .valley__front
        %svg{:height => "134px", :version => "1.1", :viewbox => "0 0 400 134", :width => "400px", :xmlns => "http://www.w3.org/2000/svg", "xmlns:xlink" => "http://www.w3.org/1999/xlink"}
          %defs
          %g#Page-1{:fill => "none", "fill-rule" => "evenodd", :stroke => "none", "stroke-width" => "1"}
            %path#Path-2-Copy{:d => "M5.82289818e-14,0.992462306 C33.0247396,-1.43201686 55.4348958,0.585561264 67.2304688,7.04519668 C84.9238281,16.7346498 85.4863281,33.9143373 109.171875,33.9143373 C118.378798,33.9143373 127.026363,33.7060794 135.206919,33.524919 C162.577198,32.9187977 184.719696,32.6160113 205.093229,41.4313783 C220.081995,47.9168255 225.761719,80.8928529 248.896484,80.8928529 C300.989173,80.8928529 309.31576,85.3513421 325.396484,73.9905092 C335.683594,66.7227937 341.029297,48.8205873 399.240234,49.7014467 C399.240234,97.5256654 399.280599,125.440379 399.361328,133.445587 C395.573568,133.445587 349.9375,133.445587 262.453125,133.445587 C174.96875,133.445587 87.484375,133.445587 5.68434189e-14,133.445587 L5.82289818e-14,0.992462306 Z", :fill => "#400222"}
    .horizon.horizon--below
    .mountain-front
    .mountain-middle
    .circles
      .circles__item
      .circles__item
      .circles__item
      .circles__item
      .circles__item
    .bird
      
    .description
      %span A scene inspired by 
      %a{ :href => "https://dribbble.com/shots/3711575-Little-Mountains" }
        Alex Pasquarella's illustration
      %p (move the mouse around to move the scene)
            
          
!
            
              $color-background: #400222;
$color-sky--darker: #E75323;
$color-lighter-yellow: #FFC55D; 
$color-mid-orange: #FE9323;
$color-red: #B12129;
$sun-size: 5em;
$sun-position-top: 4em;
$sun: (
  0: #fff,
  1: #FFC55D,
  2: #FE9323,
  3: #E75323
);

$scene-width: 33em;

$cubic-bezier: cubic-bezier(0.680, -0.550, 0.265, 1.550);

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

body {
  background-color: $color-background;
}

.container {
  display: flex;
  width: 100%;
  align-items: center;
  justify-content: center;
  transform: perspective(1000px) transformZ(0);
  transform-style: preserve-3d;
  will-change: transform;
  transition: transform .1s ease-in-out;
  
  @media screen and (max-width: 600px) {
  transform: scale(.6);
  }
}

.cloud__obj { display: none; }

.clouds {
  position: relative;
  transform: translateZ(5em);
  z-index: 7;
}

.clouds__cloud {
  transform: scale(.2);
  position: absolute;
  height: 270px;
  width: 550px;
  z-index: 7;

  &.clouds__cloud-1 {
    top: -3em; left: -55%;
    animation: 59s cloud1 ease-in-out infinite alternate;
  }
  &.clouds__cloud-2 {
    top: -7em; left: -10%;
    animation: 49s d ease-in-out infinite alternate;
  }
  &.clouds__cloud-3 {
    top: -3.3em; right: -50%;
    transform: rotateY(180deg) scale(.22);
    clip-path: polygon(0% 0%, 100% 0%, 100% 48%, 0% 48%);
  }
}

.wrapper {
  background-color: $color-sky--darker;
  min-width: $scene-width;
  height: 24em;
  position: relative;
  transition: filter .5s ease-in-out;
  top: 20vh;
}

.horizon {
  width: $scene-width - 13em;
  background: $color-mid-orange;
  height: 5em;
  top: 5em;
  z-index: 6;
  position: relative;

  &:after {
    width: 4em;
    background: $color-mid-orange;
    z-index: 6;
    height: 5em;
    top: 0;
    position: absolute;
    right: -13em;
    content: "";
  }
}

.horizon--below {
  background: $color-lighter-yellow;
  width: 100%;
  margin-top: -1em;
  overflow: hidden;

  &:after { content: none; }
  &:before {
    content: "";
    clip-path: unset;
    width: 4em; height: 4em;
    background: $color-mid-orange;
    position: absolute;
    top: 1em;
    left: -2em;
    transform: rotate(45deg);
  }
}

.sun {
  position: absolute;
  z-index: 4;
  right: 6em;
  top: $sun-position-top;
  width: $sun-size;
  height: $sun-size;
  background-color: map-get($sun, 0);
  box-shadow:
     0 0 0 2em map-get($sun, 1),
     0 0 0 4em map-get($sun, 2),
     0 0 0 6em map-get($sun, 3);
  border-radius: 50%;
}

.balloon {
  position: absolute;
  transform: translateZ(2em);
  top: -1em;
  left: 6em;
  background: linear-gradient(
    90deg
    , $color-red 0%
    , $color-red 50%
    , $color-lighter-yellow 50%
    , $color-lighter-yellow 100%
  );
  height: 7em;
  width: 7em;
  border-radius: 50%;
  z-index: 8;
  animation: 9s balloon ease-in-out infinite alternate;

  &:before {
    content: "";
    height: 7em;
    display: block;
    width: 3.5em;
    top: 0;
    left: 1.75em;
    z-index: 8;
    position: relative;
    border-radius: 50%;
    background: linear-gradient(
    90deg
    , $color-sky--darker 0%
    , $color-sky--darker 50%
    , $color-mid-orange 50%
    , $color-mid-orange 100%
  );
  }

  &:after {
    width: 1em;
    height: 1em;
    content: "";
    background: #111;
    left: 3em;
    bottom: -1.5em;
    position: absolute;
  }
}

.tree {
  border-left: 1rem solid transparent;
  border-right: 1rem solid transparent;
  border-bottom: 4rem solid $color-background;
  position: absolute;
  z-index: 10;
  top: -9.5em; left: 2em;

  &--red {
    border-bottom: 4rem solid $color-red;
  }
}

@mixin tree($x, $y, $color) {
  border-left: 1rem solid transparent;
  border-right: 1rem solid transparent;
  border-bottom: 4rem solid $color-background;
  position: absolute;
  z-index: 10;
}

.valley {
  position: absolute;
  width: 100%;
  top: 22em;
  z-index: 10;
  transform: translateZ(1em);

  .tree {
    &:nth-child(2) { top: -7em; left: 7em; }
    &:nth-child(3) { top: -6em; left: 8em; }
    &:nth-child(4) { top: -1.5em; left: 19em; }
    &:nth-child(5) { top: -3.5em; left: 19em; border-bottom: 9rem solid $color-background; border-left: 2rem solid transparent; height: 6em;
    border-right: 2rem solid transparent; }
    &:nth-child(6) { top: -4.5em; left: 29em; }
  }
}

.valley__front {
  position: absolute;
  z-index: 9;
  height: 5em;
  bottom: 0;
  left: 4em;
  transform: scale(1.4);
}

.valley__back {
  position: absolute;
  transform-style: preserve-3d;
  bottom: -2em;
  transform: scale(1.47);
  right: 2.58em;
  z-index: 8;

  .tree {
    &:nth-child(1) { top: 1em; left: 1.5em; }
    &:nth-child(2) { top: 1.2em; left: 2.2em; }
    &:nth-child(3) { top: -.7em; left: 6em; }
    &:nth-child(4) { top: -1.5em; left: 9em; }
  }
}

.mountain-middle {
  width: 20em;
  height: 20em;
  position: absolute;
  z-index: 6;
  background: $color-red;
  top: 5em;
  left: -3em;
  clip-path: polygon(15% 35%, 23% 27%, 27% 31%, 33% 25%, 38% 29%, 41% 23%, 63% 39%, 76% 42%, 80% 37%, 84% 42%, 89% 38%, 95% 44%, 95% 91%, 15% 92%);
}

.mountain-front {
  width: 20em;
  height: 20em;
  background: $color-mid-orange;
  position: relative;
  top: -4.5em;
  left: 2em;
  z-index: 7;
  clip-path: polygon(19% 15%, 19% 39%, 3% 55%, 19% 55%, 52% 90%, 66% 90%, 100% 63%, 68% 31%, 68% 64%);

  &:before {
    content: "";
    width: 5em;
    height: 5em;
    border-right: 5px solid white;
    position: absolute;
    background: #fff;
    left: 2em;
    top: 0;
  }
}

.circles { position: absolute; top: 0; }

.circles__item {
  width: .7rem;
  height: .7rem;
  background-color: $color-lighter-yellow;
  border-radius: 50%;
  position: relative;
  z-index: 11;

  &:nth-child(1) { top: 2em; left: 2em; }
  &:nth-child(2) { top: 11em; left: 4em; }
  &:nth-child(3) { top: 14em; left: 17em; background: $color-red }
  &:nth-child(4) { top: 17em; left: 27em; background: $color-lighter-yellow; }
  &:nth-child(5) { top: 18em; left: 25em; background: $color-sky--darker; }
}

.cordilheira {
  background-color: $color-sky--darker;
  position: absolute;
  width: 3em;
  height: 3em;
  transform: rotate(45deg);
  top: 12.5em;
  left: 20em;
  z-index: 7;
  &:after {
    content: '';
    background-color: $color-sky--darker;
    position: absolute;
    left: 2.5em;
    width: 2.5em;
    top: -2em;
    height: 2.5em;
  }
}

.bird {
  position: absolute;
  top: 7em;
  right: 4em;
  content: "";
  width: 1em;
  z-index: 8;
  animation: .5s wings ease-in-out infinite alternate,
             10s birdMove linear infinite alternate;
  border-radius: 50% 50% 0 0;
}

.description {
  color: #fff;
  text-align: center;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol";
  font-size: .8rem;
  a { color: $color-mid-orange; }
  
  p { font-size: .6rem; }
}

@keyframes wings {
  from {
    border-top: 1px solid black;
    border-left: 1px solid black;
    border-right: 1px solid black;
    height: .4em;
  }

  to {
    border-top: 2px solid black;
    border-left: 2px solid black;
    border-right: 2px solid black;
    height: 0;
  }
}

@keyframes birdMove {
  from { transform: translateX(5em) translateY(2em) scale(1); }
  to { transform: translateX(-5em) translateY(0) scale(.7);}
}

@keyframes cloud1 {
  from { transform: translateX(0%) scale(.2); }
  to { transform: translateX(20%) scale(.2);}
}

@keyframes d {
  from { transform: translateX(40%) scale(.2); }
  to { transform: translateX(10%) scale(.2);}
}

@keyframes balloon {
  0% {
    transform: translateX(0) translateZ(2em);
  }

  50% {
    transform: translateX(1em) translateY(.5em) translateZ(2em);
  }

  100% {
    transform: translateX(1.5em) translateY(.9em) translateZ(2em);
  }
}

            
          
!
            
              const w = window.innerWidth / 2;
const h = window.innerHeight / 2;
let request;

const wrapper = document.querySelector('.container');

document.addEventListener('mousemove', mouseMove);
document.addEventListener('ontouchmove', mouseMove);

function mouseMove(e) {
  const pos = { x: 0, y: 0 };
  pos.x = e.clientX;
  pos.y = e.clientY;

  cancelAnimationFrame(request);
  request = requestAnimationFrame(update.bind(this, pos));
}

function update(coords) {
  let dx = coords.x - w;
  let dy = coords.y - h;
  let tiltx = dy / h;
  let tilty = -dx / w;
  let radius = Math.sqrt(Math.pow(tiltx, 2) + Math.pow(tilty, 2));
  let degree = radius * 7;

  const string3d = `rotate3d(${tiltx}, ${tilty}, 0, ${degree}deg)`;
  wrapper.style.transform = string3d;
}

            
          
!
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.
Loading ..................

Console