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. You can use the CSS from another Pen by using it's URL and the proper URL extention.

+ 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

              
                <head>
 <link href='https://fonts.googleapis.com/css?family=Orbitron:400,500' rel='stylesheet' type='text/css'>
</head>

<body>
		<div id="calculator" class="container">
			<div id="display" class="row-fluid"><!--want to change it to input but this screws everything up -->
	</div> 
        <div id="special" class="row-fluid buttons">				      
				        <button id="clearall"><img src="https://s3-us-west-2.amazonaws.com/s.cdpn.io/410958/clearall.png" alt="on/c" /><span class="button-text"></span></button>
          				<button id="off"><img src="https://s3-us-west-2.amazonaws.com/s.cdpn.io/410958/off.png" alt="off"/></button>
          <button id="clear"><img src="https://s3-us-west-2.amazonaws.com/s.cdpn.io/410958/ce.png" alt="ce"/></button>
          <button id="equals"><img src="https://s3-us-west-2.amazonaws.com/s.cdpn.io/410958/equals.png" alt="="/></button>
        </div>
<div id="badcols" class= "row-fluid buttons">
			<div id="numbers" class="col-xs-10">
<button id="seven"><img src="https://s3-us-west-2.amazonaws.com/s.cdpn.io/410958/seven.png"     alt="7"/><span class="button-text">7</span></button>
				<button id="eight"><img src="https://s3-us-west-2.amazonaws.com/s.cdpn.io/410958/eight.png" alt="8"/><span class="button-text">8</span></button>
				<button id="nine"><img src="https://s3-us-west-2.amazonaws.com/s.cdpn.io/410958/nine.png" alt="9"/><span class="button-text">9</span></button>
				<button id="four"><img src="https://s3-us-west-2.amazonaws.com/s.cdpn.io/410958/four.png" alt="4"/><span class="button-text">4</span></button>
				<button id="five"><img src="https://s3-us-west-2.amazonaws.com/s.cdpn.io/410958/five.png" alt="5"/><span class="button-text">5</span></button>
				<button id="six"><img src="https://s3-us-west-2.amazonaws.com/s.cdpn.io/410958/six.png" alt="6"/><span class="button-text">6</span></button>
				<button id="one"><img src="https://s3-us-west-2.amazonaws.com/s.cdpn.io/410958/one.png" alt="1"/><span class="button-text">1</span></button>
				<button id="two"><img src="https://s3-us-west-2.amazonaws.com/s.cdpn.io/410958/two.png" alt="2"/><span class="button-text">2</span></button>
				<button id="three"><img src="https://s3-us-west-2.amazonaws.com/s.cdpn.io/410958/three.png" alt="3"/><span class="button-text">3</span></button>
				<button id="zero"><img src="https://s3-us-west-2.amazonaws.com/s.cdpn.io/410958/zero.png" alt="0"/><span class="button-text">0</span></button>
				<button id="dot"><img src="https://s3-us-west-2.amazonaws.com/s.cdpn.io/410958/dot.png" alt="."/><span class="button-text">.</span></button>
				<button id="percent"><img src="https://s3-us-west-2.amazonaws.com/s.cdpn.io/410958/percent.png" alt="%"/></button>

			</div>
<div id="operators" class="col-xs-2">
		<button><img src="https://s3-us-west-2.amazonaws.com/s.cdpn.io/410958/over.png" alt="/"/><span class="button-text">/</span></button>
  <button><img src="https://s3-us-west-2.amazonaws.com/s.cdpn.io/410958/minus.png" alt="-"/><span class="button-text">-</span></button>
				<button><img src="https://s3-us-west-2.amazonaws.com/s.cdpn.io/410958/times.png" alt="*"/><span class="button-text">*</span></button>
  <button><img src="https://s3-us-west-2.amazonaws.com/s.cdpn.io/410958/plus.png" alt="+"/><span class="button-text">+</span></button>
			</div>
  </div>    
		</div>
	</body>

              
            
!

CSS

              
                body, div, input, button {
    padding:0;
    margin:0;    
}

body {
  background-color: #9C9F84;
  
}

#calculator {
  background-image: url('https://s3-us-west-2.amazonaws.com/s.cdpn.io/410958/calctransparentclean.png');
  background-size:100% auto;
  background-repeat:no-repeat;
  background-color: #9C9F84;
	width: 340px;
	height: 530px;
  margin: 0px auto;
	padding: 5px;
}

#display {
    height: 35px;
    width: 188px;
    margin:auto;
    background-color:transparent;
    opacity:.72;
    margin: 158px 76px 40px;
    text-align: right;
    line-height: 38px;
    font-size: 30px;
    padding: 0 4px 0 5px;
    border-radius: 7%;
    font-family: 'Orbitron', sans-serif; 
     -ms-transform: rotate(1deg); /* IE 9 */
    -webkit-transform: rotate(1deg); /* Safari */
    transform: rotate(.8deg);
}
#display.on {
  background: rgba(0,255, 50, .3);
  box-shadow: inset 0px 0px 12px 0px #b1ffc0;
}
.buttons {
  -ms-transform: rotate(1deg); /* IE 9 */
    -webkit-transform: rotate(1deg); /* Safari */
    transform: rotate(.3deg);
}

button {
  background-color:transparent;
  border: none;
  padding:none;
  margin:none;
  border-radius: 20px;
}
button:focus {
   outline:none !important;
}

button img:hover {
   opacity:.92;  
}
button img:active {
  transform:scale(1.05,1.05);
    -webkit-transform:scale(1.05,1.05);
    -moz-transform:scale(1.05,1.05);
}

button img {
  display:block;
  width: 57px;
  height: 50px; 
  float: left;
  border-radius: 15px;
  background: transparent;
  opacity: 1;
}

.button-text {
  display:none;
}


#special {
  position:relative;
   margin:auto;
  float: left;
  padding-left:49px;
}
#badcols {
  position:relative;
   margin:auto;
  float: left;
  padding-left: 34px;
  padding-right: 59px; 
}
#operators{
  float:left;
  margin: auto;
  padding-left:0px;
  
}
#numbers {
 padding-right: 0px; 
}

              
            
!

JS

              
                $(document).ready(function(){
  
  //makes sure the number doesn't spill out of the display 
	var testNumLength = function(number) {
        if (number.toString().length > 7) {
          if (number >= 9999999) {
            display.text("Err");
          }
        else if (number.toString().match(/e/)){
           display.text(number.toFixed(6));
         } //& tries to do something about javascript's occasional weird use of exponential notation which I do not fully comprehend
         else {
       display.text(number.toString().substr(0,7));
         }   
        }  
      if ((number == Infinity) || ((number != ".") && isNaN(number))) {
      display.text("Err");
    }//& returns 'Err' just like old tyme calculators
    };
   var turnOff = function(){ 
       display.text("");
       display.removeClass("on");
    };
	  var number = "";
    var newnumber = "";
    var operator = "";
    var justCalculated = false;
    var display = $("#display"); 
    display.text(""); 
  //NUMBERS
    $("#numbers button").not("#percent").click(function(){
      if (justCalculated === true){ //so that it won't append #s when you're trying to start a new calculation
        number = "";
        newnumber = "";
        operator = "";
        justCalculated = false;
      }
    display.addClass("on");
		number += $(this).text();
		display.text(number);
		testNumLength(number);
    });
  //OPERATORS
    $("#operators button").click(function(){    
        if (justCalculated === true){
        operator = "";
        number = newnumber;
        justCalculated = false;
      }
      if (operator === ""){
        operator = $(this).text();
		    newnumber = number; 
		    number = ""; 
      }
      
      else if (operator === "+"){
        operator = $(this).text();
         newnumber = (parseFloat(newnumber) + parseFloat(number));
		    number = ""; 
		    display.text(newnumber.toString());
        testNumLength(newnumber);
      }
      else if (operator === "-"){
        operator = $(this).text();
        newnumber = (parseFloat(newnumber) - parseFloat(number));
		    number = ""; 
		    display.text(newnumber.toString());
        testNumLength(newnumber);
      }
      else if (operator === "*"){
        operator = $(this).text();
         newnumber = (parseFloat(newnumber) * parseFloat(number));
		    number = ""; 
		    display.text(newnumber.toString());
        testNumLength(newnumber);
      }
      else if (operator === "/"){
         operator = $(this).text();
         newnumber = (parseFloat(newnumber) / parseFloat(number));
		    number = ""; 
		    display.text(newnumber.toString());
        testNumLength(newnumber);
      }
    });
 //CLEAR BUTTONS
  $("#clear,#clearall").click(function(){
		number = "";
		display.text("0");
		if ($(this).attr("id") === "clearall") { //resets everything but keeps it "on"
      display.addClass("on");
      number = "";
			newnumber = "";
      operator = "";
      justCalculated = false;
		}
    });
  //EQUALS
    $("#equals").click(function(){
		if (operator === "+"){
			newnumber = (parseFloat(newnumber) + parseFloat(number));
		} else if (operator === "-"){
			newnumber = (parseFloat(newnumber) - parseFloat(number));
		} else if (operator === "/"){
			newnumber = (parseFloat(newnumber) / parseFloat(number));
		} else if (operator === "*"){
			newnumber = (parseFloat(newnumber) * parseFloat(number));
		}
      if (justCalculated === true){
        display.text(newnumber.toString());
        testNumLength(newnumber);
        //press the equals sign again to repeat the operation on result
      }
      else {
        display.text(newnumber.toString());
		    testNumLength(newnumber);
        justCalculated = true;
      }
    });
   $("#percent").click(function(){
    if ((operator === "+")||(operator === "-")){
      number = newnumber*(number/100);
    }
    else {
      number = (number/100);
    }
     display.text(number.toString());
    //display.text("what even is this function and why would anyone use it #millenialthoughts");
  }); 
  $("#off").click(function(){ //resets everything but turns it "off"...kind of
    turnOff();
    number = "";
    newnumber = "";
    operator = "";
    justCalculated = false;
    setTimeout(function(){
       display.text("J/K!"); // It's not a real calculator!
    }, 1800);
  });
  
  //auto power off like it says
 var autoPowerOff = setTimeout(turnOff, 30000);
 $("button" ).on( "click", function(){ 
   clearTimeout(autoPowerOff);
   autoPowerOff = setTimeout(turnOff, 20000);
 });
   
});
              
            
!
999px

Console