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 CSS

These stylesheets will be added in this order and before the code you write in the CSS editor. You can also add another Pen here, and it will pull the CSS from it. Try typing "font" or "ribbon" below.

Quick-add: + add another resource

Add External JavaScript

These scripts will run in this order and before the code in the JavaScript editor. You can also link to another Pen here, and it will run the JavaScript from it. Also try typing the name of any popular library.

Quick-add: + add another resource

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.

  <link href="https://fonts.googleapis.com/css?family=Orbitron" rel="stylesheet">

  <div class="calculator">
      <h3>FCC Calculator</h3>
        <div id="display"></div>
 <table class="grid">
    <tr class="spaceUnder">
        <td><button class="btn-red" id="AC" onclick="AC()">AC</button></td>
        <td><button class="btn-red" id="CE" onclick="CE()">CE</button></td>
        <td><button id="%" onclick="number(id)">%</button></td>
        <td><button id="/" onclick="number(id)">/</button></td>
    <tr class="spaceUnder">
        <td><button id="7" onclick="number(id)">7</button></td>
        <td><button id="8" onclick="number(id)">8</button></td>
        <td><button id="9" onclick="number(id)">9</button></td>
        <td><button id="*" onclick="number(id)">*</button></td>
    <tr class="spaceUnder">
        <td><button id="4" onclick="number(id)">4</button></td>
        <td><button id="5"  onclick="number(id)">5</button></td>
        <td><button id="6" onclick="number(id)">6</button></td>
        <td><button id="-"  onclick="number(id)">-</button></td>
    <tr class="spaceUnder">
        <td><button id="1"  onclick="number(id)">1</button></td>
        <td><button id="2" onclick="number(id)">2</button></td>
        <td><button id="3" onclick="number(id)">3</button></td>
        <td><button id="+" onclick="number(id)">+</button></td>
        <td><button id="0" onclick="number(id)">0</button></td>
    <td><button onclick="number('.')">.</button></td></tr>
        <div><button  class="wide" id="=" onclick="equals()">=</button></td>

              body {
  text-align: center;

.grid {
  position: relative;
  top: 50px;
  left: 12px;
  width: 300px;

tr.spaceUnder > td
  padding-bottom: .75em;

button {
  background: #EEEEEE;
  color: black;
  text-align: center;
  border-radius: 8px;
  width: 50px; height: 50px;
  font-size: 36px;

.btn-red {
  background: #9F000F;
  color: white;
  width: 60px;

  width: 100px;
  position: relative;
  left: 90px;
  top: -4px;

#display {
  position: absolute;
  width: 300px;  
  height: 40px;
  margin-left: 4px;
  top: 54px;
  color: #555555;
  font-size: 34px;
  text-align: right;
  font-family: 'Orbitron', sans-serif;
  font: unicode;
  background: #CCCCCC;
  border-radius: 8px;
  padding: 8px;
  box-shadow: inset 0 0 10px #777777;

.calculator {
  border: 1px;
  border-spacing: 2px;
  background: #777;
  display: inline-block;
  padding: 10px;
  border-radius: 10px;
  box-shadow: inset 0 0 16px #111111;
  position: absolute;
  height: 450px;
  width: 325px;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);

var arr=[]; // global array
var content="";
var justDidIt = 0;

function AC(){  

function CE(){
  for (var i=0; i<arr.length; i++)
    if (arr[i] == "+" ||  "-" ||  "*" ||  "/" ||  "%")
      var idx = arr.indexOf(i);

function mod(){

function equals(){
  var answer = eval(content);
  arr = [];

function number(val){
  if (justDidIt)
  content = document.getElementById('display').textContent;
  arr=content; // feed the string into the array

Loading ..................