Pen Settings

HTML

CSS

CSS Base

Vendor Prefixing

Add External Stylesheets/Pens

Any URLs 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 its URL and the proper URL extension.

+ 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

Auto Save

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

              
                .container
  .sam.bg
  .sam.body
  .sam.face
  .sam.arm
  .sam.hand
  .text
    p I want 
      strong you
    p for u.s. army
//- a(href="http://s.codepen.io/mephysto/debug/MpGNmQ") check on mobile
              
            
!

CSS

              
                @import url('https://fonts.googleapis.com/css?family=Fjalla+One');
// usage:   @include mdShadowLevel(1);
@mixin mdShadowLevel($level) {
  @if ($level == 5) {
    box-shadow: 0px 40px 70px 0px rgba(0, 0, 0, 0.22),0px 27px 24px 0px rgba(0, 0, 0, 0.2);
  } @else if ($level == 4){
    box-shadow: 0px 25px 55px 0px rgba(0, 0, 0, 0.21),0px 16px 28px 0px rgba(0, 0, 0, 0.22);
  } @else if ($level == 3){
    box-shadow: 0px 17px 50px 0px rgba(0, 0, 0, 0.19),0px 12px 15px 0px rgba(0, 0, 0, 0.24);
  } @else if ($level == 2){
    box-shadow: 0px 6px 20px 0px rgba(0, 0, 0, 0.19),0px 8px 17px 0px rgba(0, 0, 0, 0.2);
  }  @else if ($level == 1){
    box-shadow: 0px 2px 10px 0px rgba(0, 0, 0, 0.16),0px 2px 5px 0px rgba(0, 0, 0, 0.26);
  } @else{ // Aka Level 0:
    box-shadow: 0px 0px 0px 0px rgba(0, 0, 0, 0),0px 0px 0px 0px rgba(0, 0, 0, 0);
  } 
}

$multiply: 0.33;

html{
  font-size: 16px;
}
body{
  height: 100vh;
  background: #fcfbcf;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  font-family: 'Fjalla One', sans-serif;
}
.container{
  flex: 0 0 auto;
  width: 1330px * $multiply;
  height: 1790px * $multiply;
  position: relative;
  @include mdShadowLevel(1);
  perspective: 800px;
}
h1{
  margin: 0;
  color: white;
}
.bg{
  background: url("https://s3-ap-southeast-2.amazonaws.com/mephystoprojects/sam/bg.jpg");
  width: 1330px * $multiply;
  height: 1790px * $multiply;
  background-size: cover;
}

.sam{
  position: absolute;
  top: 0;
  left: 0;
}

.body{
  background: url("https://s3-ap-southeast-2.amazonaws.com/mephystoprojects/sam/body.png");
  width: 891px * $multiply;
  height: 779px * $multiply;
  background-size: cover;
    top: 484px * $multiply;
    left: 240px * $multiply;
}
.arm{
  background: url("https://s3-ap-southeast-2.amazonaws.com/mephystoprojects/sam/arm.png");
  width: 313px * $multiply;
  height: 415px * $multiply;
  background-size: cover;
  top: 716px * $multiply;
  left: 292px * $multiply;
  transform-origin: 25% 75%;
}

.hand{
  background: url("https://s3-ap-southeast-2.amazonaws.com/mephystoprojects/sam/hand.png");
  width: 186px * $multiply;
  height: 218px * $multiply;
  background-size: cover;
    top: 628px * $multiply;
    left: 520px * $multiply;
}

.face{
  background: url("https://s3-ap-southeast-2.amazonaws.com/mephystoprojects/sam/face.png");
  width: 478px * $multiply;
  height: 717px * $multiply;
  background-size: cover;
    top: 104px * $multiply;
    left: 394px * $multiply;
}
.text{
  position: absolute;
  bottom: 100px * $multiply;
  left: 0;
  width: 100%;
  p {
    color: #333;
    margin: 0;
    text-align: center;
    text-transform: uppercase;
    font-size: 3rem;
    text-shadow:
    -1px -1px 0 crimson,
    1px -1px 0 crimson,
    -1px 1px 0 crimson,
    1px 1px 0 crimson;
    strong{
      color: crimson;
      text-shadow:
      -1px -1px 0 #333,
      1px -1px 0 #333,
      -1px 1px 0 #333,
      1px 1px 0 #333;
      font-weight: normal;
      font-size: 1.2em;
    }
  }
}
pre{
  padding: 0;
  margin-top: 20px;
  margin-bottom: 0;
}
              
            
!

JS

              
                let sw = 0;
let sh = 0;
let mx = 0;
let my = 0;
let ox = 0;
let oy = 0;

var body = document.querySelector('.body');
var face = document.querySelector('.face');
var arm = document.querySelector('.arm');
var hand = document.querySelector('.hand');
var bg = document.querySelector('.bg');
var text = document.querySelector('.text');
var dist = 0;
const onMouseMove = (ev) => {
  sw = window.innerWidth * 0.5;
  sh = window.innerHeight * 0.5;
  mx = ev.clientX;
  my = ev.clientY;
  ox = ((sw - mx) / -sw).toFixed(2);
  oy = ((sh - my) / -sh).toFixed(2);
  dist = 1 + ((1 - (Math.abs(sw - mx) / sw)) * 1);
  body.style.transform = `translate3d(${ox * 10}px,${oy * 5}px,10px) rotate(${ox * 1.5}deg)`;
  arm.style.transform = `rotate(${ox * 2}deg) translate3d(${ox * 8}px, ${oy * 7}px, ${dist * 30}px)`;
  hand.style.transform = `translate3d(${ox * 10}px,${oy * 8}px, ${dist * 60}px) rotate(${ox * -5}deg)`;
  face.style.transform = `translate3d(${ox * 9}px,${oy * 5}px,25px) rotate(${ox * -3}deg)`;
  text.style.transform = `translate3d(${ox * 2}px,${oy * 2}px,10px)`;
  console.log(`mouse position: x:${mx} y:${my} `)
  console.log(`face position orientation x:${ox} y:${oy} `)
  console.log('arm translation', `rotate(${ox * 2}deg)`)
};

document.body.addEventListener('mousemove', onMouseMove);

window.addEventListener('deviceorientation', function(event) {
  var alpha    = event.alpha;
  var beta     = event.beta;
  var gamma    = event.gamma;
  
  sw = window.innerWidth * 0.5;
  sh = window.innerHeight * 0.5;
  mx = Math.max(1, gamma*100); //ev.clientX;
  my = Math.max(1, beta*100); //ev.clientY;
  ox = ((sw - mx) / -sw).toFixed(2);
  oy = ((sh - my) / -sh).toFixed(2);
  dist = 1 + ((1 - (Math.abs(sw - mx) / sw)) * 1);
  body.style.transform = `translate3d(${ox * 10}px,${oy * 5}px,10px) rotate(${ox * 1.5}deg)`;
  arm.style.transform = `rotate(${ox * 2}deg) translate3d(${ox * 8}px, ${oy * 7}px, ${dist * 30}px)`;
  hand.style.transform = `translate3d(${ox * 10}px,${oy * 8}px, ${Math.max(1, dist * 60)}px) rotate(${ox * -5}deg)`;
  face.style.transform = `translate3d(${ox * 9}px,${oy * 5}px,25px) rotate(${ox * -3}deg)`;
  text.style.transform = `translate3d(${ox * 2}px,${oy * 2}px,10px)`;
});
              
            
!
999px

Console