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

              
                
  <form name="calc" id="calculator">

    <!-- A fake product name: the FCC—2015 calculator -->
    <div class="logo">FCC&#8212;2015</div>

    <!-- Default display -->
    <div class="row">
      <textarea name="input" id="text-input" placeholder="0.0" class="columns-3 small"></textarea>
    </div>

    <div id="number-pad">
      <!-- The methematical operator buttons -->
      <div id="operations" class="float right columns-1 small">

        <input role="button" type="button" class="round button alert tiny" name="clear" value="c">
        <br>
        <input role="button" type="button" class="round operator button secondary tiny" name="div" value="/">
        <br>
        <input role="button" type="button" class="round operator button secondary tiny" name="times" value="*">
        <br>
        <input role="button" type="button" class="round operator button secondary tiny" name="minus" value="-">
        <br>
        <input role="button" type="button" class="round operator button secondary tiny" name="plus" value="+">
      </div>

      <!-- The number buttons proper, plus decimal and equals -->
      <div class="columns-9 small">
        <div class="row">
          <input role="button" type="button" class="number button" name="one" value="1">

          <input role="button" type="button" class="number button" name="two" value="2">

          <input role="button" type="button" class="number button" name="three" value="3">
        </div>

        <div class="row">
          <input role="button" type="button" class="number button" name="four" value="4">

          <input role="button" type="button" class="number button" name="five" value="5">

          <input role="button" type="button" class="number button" name="six" value="6">
        </div>

        <div class="row">
          <input role="button" type="button" class="number button" name="seven" value="7">

          <input role="button" type="button" class="number button" name="eight" value="8">

          <input role="button" type="button" class="number button" name="nine" value="9">
        </div>

        <div class="row">
          <input role="button" type="button" class="number button" name="zero" value="0">

          <input role="button" type="button" class="round number button info" name="dot" value=".">

          <input role="button" type="button" class="round button success" name="equals" value="=">
        </div>
      </div>
    </div>
  </form>

  <!-- Fake calulator body in a layer behind the buttons -->
  <div class="calc-body">
    <span>
    <span class="calc-top"></span>
    <span class="calc-bottom"></span>
    <span class="calc-left"></span>
    <span class="calc-right"></span>
    <span class="calc-center"></span>
    </span>
  </div>

<button class="flipper">Flip it!</button>
              
            
!

CSS

              
                * {
  box-sizing: border-box;
  outline: 0;
  transform-style:
}

html {
  height: 620px;
  max-width: 100vw;
}

body {
  background: url(http://cdn.backgroundhost.com/backgrounds/subtlepatterns/purty_wood.png);
  max-height: 620px;
  margin: 2em auto;
  display: flex;
  justify-content: center;
  align-items: top;
  font-family: 'avenir next', avenir, helvetica, 'helvetica neue', arial, sans-serif;
  overflow-y: hidden;
  overflow-x: hidden;
}

textarea,
textarea:focus {
  color: #ddd;
  font-family: 'Press Start 2P', monospace;
  font-size: 1.5em;
  text-align: right;
  resize: none;
  overflow: hidden;
  white-space: nowrap;
  background: #333;
  min-height: 2.5em;
  padding: .5em;
  box-shadow: inset 0 0 .5em rgba(200, 200, 200, 1);
}

#calculator {
  position: absolute;
  top: 0;
  left: 0;
  bottom: 0;
  right: 0;
  width: 30em;
  max-width: 100vw;
  margin: 0 auto;
  z-index: 100;
  transform: translateZ(1px);
}

/* Fake Calculator Body */
.calc-body {
  z-index: -1;
}

.calc-body > span {
  position: relative;
  display: inline-block;
  width: 60em;
  height: 60em;
}

.calc-top {
  display: inline-block;
  position: absolute;
  top: 0;
  left: 13.75em;
  width: 32.5em;
  height: 7.2em;
  background-color: #AAA;
  background: url(http://cdn.backgroundhost.com/backgrounds/subtlepatterns/white_carbonfiber.png);
  border-radius: 1em 1em 0 0;
  box-shadow: 0em 2em 3em rgba(0, 0, 0, .75);
  border: .25em solid #DDD;
}

.logo {
  font-family: Audiowide;
  color: #555;
  font-size: .8em;
  margin: .5em 0 0 0;
}

.calc-bottom {
  display: inline-block;
  position: absolute;
  top: 28.3em;
  left: 5.9em;
  width: 48.25em;
  height: 2.875em;
  background: url(http://cdn.backgroundhost.com/backgrounds/subtlepatterns/white_carbonfiber.png);
  border-radius: 0 0 2.5em 2.5em;
  box-shadow: 0em 1em 2em rgba(0, 0, 0, .5);
  border-top: .5em solid #DDD;
}

.calc-left {
  display: inline-block;
  position: absolute;
  top: 6.8em;
  left: 5.875em;
  border-style: solid;
  border-width: 0 0 21.5em 7.875em;
  border-color: transparent transparent #eee transparent;
}

.calc-right {
  display: inline-block;
  position: absolute;
  top: 6.8em;
  left: 46.25em;
  border-style: solid;
  border-width: 0 7.875em 21.5em 0;
  border-color: transparent transparent #eee transparent;
}

.calc-center {
  display: inline-block;
  position: absolute;
  top: 6.8em;
  left: 13.75em;
  width: 32.5em;
  height: 21.5em;
  background-color: #eee;
}

/* Button styles */
.button {
  font-family: Orbitron;
  width: 6.5em;
  margin: .5em;
  background: rgba(0, 116, 217, .8);
  box-shadow: 0 .3em 0 rgba(0, 116, 217, .4);
}

.success {
  box-shadow: 0 .3em 0 rgba(0, 180, 50, .5);
}

.info {
  background: rgba(50, 150, 250, .65) !important;
  box-shadow: 0 .3em 0 rgba(50, 150, 250, .325);
}

.button.alert {
  box-shadow: 0 .3em 0 rgba(250, 100, 50, .5);
}

.button.secondary {
  box-shadow: 0 .3em 0 rgba(200, 200, 200, .5);
}

.button:hover {
  box-shadow: 0px 4px #999;
}

/* Imitate a pressed effect for buttons */
.button:active {
  box-shadow: 0 0 #666;
  top: .1em;
}

#operations {
  font-size: .8em;
  margin: 0 1em;
}

.tiny {
  width: 4em;
}

#text-input {
  text-align: right;
  font-size: 1.8em;
  line-height: 1.8em;
}

#operations input {
  font-size: 1.1em;
  font-weight: bold;
}

#number-pad {
  transform: perspective(30em) rotateX(30deg);
}



body.transform {
  transform:rotate(180deg);
  -ms-transform:rotate(180deg);
  -webkit-transform:rotate(180deg);
}
.flipper {
  display: none;
}

/* For mobile */
@media only screen and (min-width: 320px) and (max-width: 800px) and (orientation: portrait),
  only screen and (min-width: 320px) and (max-width: 800px) and (orientation: landscape) {
    body, html {
      max-height: 600px;
    }
    #number-pad {
      transform: initial;
    }
    .number,
    .success {
      font-size: 2.5em;
      padding: .25em 0 .2em;
      margin: .25em 0 .015em 0;
      width: 1.7em;
    }
    #calculator,
    .calc-center,
    .calc-top,
    .calc-bottom {
      width: 20em !important;
      margin: 0 auto;
    }
    .calc-center {
      height: 21.5em;
    }
    .calc-bottom {
      left: 13.75em;
      top: 28.25em;
    }
    .calc-body > span {
      position: relative;
      display: inline-block;
      width: 48.5em;
    }
    .calc-left,
    .calc-right {
      display: none;
    }
    .button {
      box-shadow: 0 .1em 0 rgba(0, 116, 217, .4);
    }
    .button:active {
      box-shadow: 0 0 #666;
      top: .025em;
    }
    .logo {
      padding: .2em 0 0 .3em;
    }
    #text-input {
      width: 95%;
    }
    #operations input {
      height: 3.6em;
    }
    html {
      max-width: 100%;
      overflow-x: hidden;
    }
    #text-input {
      text-align: right;
      font-size: 1.2em;
      line-height: 2.8em;
      height: 3.8em;
    }
    .flipper {
      background-color: rgba(250,250,255,.4);
      color: #444;
      border: none;
      padding: 1em;
      position: absolute;
      bottom: 0;
      right: 0;
      display: block;
    }
}


              
            
!

JS

              
                $('.number').on('click', function() {
  calc.input.value += this.value;
});

$('.operator').on('click', function() {
  calc.input.value += this.value;
});

$('[name="equals"]').on('click', function() {
  calc.input.value = parseFloat(eval(calc.input.value).toFixed(3));
});

$('[name="clear"]').on('click', function() {
  calc.input.value = '';
});

var maxLength = 15;

/* Restrict input characters */
$('#text-input').keypress(function(e) {
  var validKeys = String.fromCharCode(e.which);
  if ('.0123456789'.indexOf(validKeys) < 0) {
    return false;
  }
  if (calc.input.value.length === maxLength) {
    e.preventDefault();
    calc.input.value = '';
    $('#text-input').attr('placeholder', 'ERROR!')
  }
});

$('#text-input').keyup(function(e) {
  if (e.shiftKey && e.which === 187 || e.which === 107) { // plus sign
    $('[value="+"]').click();
  }
  if (e.which === 189 || e.which === 109) { // minus sign
    $('[value="-"]').click();
  }
  if (e.shiftKey && e.which === 56 || e.which === 106) { // multiplication sign
    $('[value="*"]').click();
  }
  if (e.which === 191 || e.which === 111) { // division sign
    $('[value="/"]').click();
  }
  if (e.which === 13 || e.which === 187) { // equals sign or enter key
    $('[value="="]').click();
  }
  if (e.which === 27 || e.which === 67) { // c or esc
    $('[name="clear"]').click();
  }
});

$('.flipperBtn').on('click', function() {
  $('.wrapper').toggleClass('.flipper');
})

$('.flipper').on('click', function() {
  $('body').toggleClass('transform');
})
              
            
!
999px

Console