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

              
                <meta name="viewport" content="width=device-width, initial-scale=1">
<link href='https://fonts.googleapis.com/css?family=Open+Sans:400,300,300italic,400italic,600,600italic,700,700italic,800,800italic' rel='stylesheet' type='text/css'>
<script src="https://code.jquery.com/jquery-2.2.0.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/mathjs/2.6.0/math.min.js"></script>
<script src="path/to/vanilla.js"></script>
<!--Calculator canvas-->
<div id="wrapper">
  <div id="wrapperTwo">
    <!--Screen-->
    <div class="screen">
      <div id="inputSec" name="display" class="numbers"></div>
    </div>
    <!--Screen-->
    <!--Buttons-->
    <div class="buttons">
      <!--Operators and other keys-->
      <button class="numBut" data-num="7">7</button>
      <button class="numBut" data-num="8">8</button>
      <button class="numBut" data-num="9">9</button>
      <button class="op" data-op="/">/</button>

      <button class="numBut" data-num="4">4</button>
      <button class="numBut" data-num="5">5</button>
      <button class="numBut" data-num="6">6</button>
      <button class="op" data-op="*">*</button>

      <button class="numBut" data-num="1">1</button>
      <button class="numBut" data-num="2">2</button>
      <button class="numBut" data-num="3">3</button>
      <button class="op" data-op="-">-</button>

      <button class="numBut" data-num="0">0</button>
      <button class="decimal" data-num=".">.</button>
      <button class="modulo" data-num="%">%</button>
      <button class="op" data-num="+">+</button>

      <button class="clear" onclick="C()">Clear</button>
      <button class="equal" data-result="" onclick="total()">=</button>
      <!--Operators and other keys-->
    </div>
    <!--Buttons-->
  </div>
</div>
<!--Calculator canvas-->
              
            
!

CSS

              
                * {
  box-sizing: border-box;
}

body,
html {
  margin: 0;
  padding: 0;
}

body {
  background-color: #F9690E;
  /* IE10+ */
  background-image: -ms-radial-gradient(center top, ellipse farthest-corner, #F9690E 0%, #22313F 100%);
  /* Mozilla Firefox */
  background-image: -moz-radial-gradient(center top, ellipse farthest-corner, #F9690E 0%, #22313F 100%);
  /* Opera */
  background-image: -o-radial-gradient(center top, ellipse farthest-corner, #F9690E 0%, #22313F 100%);
  /* Webkit (Safari/Chrome 10) */
  background-image: -webkit-gradient(radial, center top, 0, center top, 359, color-stop(0, #F9690E), color-stop(100, #22313F));
  /* Webkit (Chrome 11+) */
  background-image: -webkit-radial-gradient(center top, ellipse farthest-corner, #F9690E 0%, #22313F 100%);
  /* W3C Markup */
  background-image: radial-gradient(ellipse farthest-corner at center top, #F9690E 0%, #22313F 100%);
  background-attachment: fixed;
  background-size: cover;
  font-family: 'Open Sans', sans-serif;
  font-weight: 400;
}

#wrapper {
  background-color: #FFFFFF;
  width: 500px;
  height: auto;
  margin: 50px auto 50px;
  position: relative;
  overflow: hidden;
  padding: 20px;
}

#wrapperTwo {
  padding: 32px;
  margin: 0 0 0 18px;
}

.screen {
  border: none;
  margin: 0 auto;
}

#inputSec {
  border: none;
  background-color: #ecf0f1;
  width: 358px;
  height: 100px;
  overflow: hidden;
  padding: 7% 2% 6%;
  font-size: 36px;
  text-align: right;
}

button {
  border: none;
  background-color: #F9690E;
  font-family: 'Open Sans', sans-serif;
  font-weight: 400;
  font-size: 24px;
  color: #22313F;
  width: 75px;
  height: 75px;
  margin: 20px 15px 0 0;
  text-align: center;
}

button:hover {
  background-color: #22313F;
  color: #F9690E;
}

button.equal {
  width: 263px;
}
              
            
!

JS

              
                // Access the screen object
var screen = $('.screen');
var resetScreen = "0";
var value = "";
var input = "";
// upgradeScreen(resetScreen);
// document.getElementById("screen").innerHTML = value;
$('.numBut').click(function() {
  var input = $("#inputSec").text();
  input += $(this).text();
  $('#inputSec').text(numToString(input));
});

function C() {
  $('.clear').click(function() {
    $('#inputSec').text("");
    input = "";
    return [str.charAt()];
  });
};

function numToString(str) {
  var change = Number(str);
  var change = change.toString();
  return change;
}

console.log(numToString("002"));

var operators = ["/", "*", "-", "+"];
var decimalAdded = false;

var block = "";
$(".op").click(function() {
  var input = $("#inputSec").text();
  input += $(this).text();
  $("#inputSec").text(input);

});

function total() {
  console.log($(this).text());
  var input = $("#inputSec").text();
  $('#inputSec').text(math.eval(input));
}

result = parseFloat(nr[0]);
for (k = 0; k < nr.length; k++) {
  if (operators[op] === "+" && k !== nr.length - 1) {
    result = result + parseFloat(nr[k + 1]);
  }
}

$('.decimal').click(function() {
  input += $(this).text();
  $('#inputSec').text('.');
});

$('.modulo').click(function() {
  input += $(this).text();
  $('#inputSec').text('%');
});
enterNumbers();
              
            
!
999px

Console