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

              
                <!-- all rights reserved -->
<!-- all design and code by Kyle Jensen -->
<div class="calc">
  <div id="logo"> 
    <p>asThe_Water_Falls</p>
    <p>&copy2017</p>
  </div>
  <div id="screen">
    <div id="screenRow1">
      <p class="expression"></p>
    </div>
    <div id="screenRow2">
      <p class="total"></p>
    </div>
  </div>
  <div class="row">
    <input id="allClear" type="button" value="AC">
    <input id="clear" type="button" value="C">
    <input id="divide" type="button" value="/">
    <input id="multiply" type="button" value="*">
  </div>
  <div class="row">
    <input id="one" type="button" value="1">
    <input id="two" type="button" value="2">
    <input id="three" type="button" value="3">
    <input id="minus" type="button" value="-">
  </div>
  <div class="row">
    <input id="four" type="button" value="4">
    <input id="five" type="button" value="5">
    <input id="six" type="button" value="6">
    <input id="plus" type="button" value="+">
  </div>
  <div class="row">
    <input id="seven" type="button" value="7">
    <input id="eight" type="button" value="8">
    <input id="nine" type="button" value="9">
    <input id="zero" type="button" value="0">
  </div>
  <input id="equals" type="button" value="=">
</div>
              
            
!

CSS

              
                body {
  padding: 0;
  margin: 0;
  background-color: #3f3f3f;
}

.row,
#screenRow1,
#screenRow2 {
    display: -ms-flexbox;
    display: -webkit-box;
    display: flex;
    display: -ms-flex;
    display: -moz-flex;
    display: -webkit-flex;
}

.calc { 
    background-color: #42282e; /*default*/
    width: 200px;
    height: 370px;
    border-radius: 5px;
    margin: 20px auto;
    -webkit-box-shadow: 1px 2px 8px 3px rgba(0,0,0,.5);
            box-shadow: 1px 2px 8px 3px rgba(0,0,0,.5);
    background-image: -webkit-gradient(linear,  
      left top, right top,  
      from(#6d5d60),
      color-stop(3%, #5e4a4e),
      color-stop(97%, #42282e),
      color-stop(99.5%, #5e4a4e),
      color-stop(99.8%, #6d5d60)
      );
    background-image: linear-gradient(to right,  
      #6d5d60,
      #5e4a4e 3%,
      #42282e 97%,
      #5e4a4e 99.5%,
      #6d5d60 99.8%
      );
}

#logo {
  position: relative;
  height: 80px;
  color: #f4f1d6;
  text-align: center;
  line-height: .5px;
  font-size: 12px;
}

#logo p {
  text-shadow: 1px 1px 5px rgba(0,0,0,.5);
  position: relative;
  z-index: 999999;
}

#logo p:nth-child(1) {
  padding-top: 35px;
}

#logo p:nth-child(2) {
  left: 30px;
}

.row {
  -ms-flex-pack: center;
      -webkit-box-pack: center;
          justify-content: center;
  -ms-flex-direction: row wrap;
      -webkit-box-orient: horizontal;
      -webkit-box-direction: normal;
          flex-direction: row wrap;
  height: 40px;
  width: 170px;
  margin: 1px auto;
}

#screen {
  position: relative;
  height: 60px;
  width: 166px;
  margin: 2px auto;
  background-color: #f4f1d6;
  border-radius: 2px;
  -webkit-box-shadow: inset 1px 1px 1px 1px rgba(0,0,0,.5),
              inset -1px -1px .5px #3f3f3f;
          box-shadow: inset 1px 1px 1px 1px rgba(0,0,0,.5),
              inset -1px -1px .5px #3f3f3f;
  font-size: 25px;
  overflow: hidden;
}

#screenRow1 {
  height: 20px;
  margin: 3px;
  padding: 0 5px 0;
  -ms-flex-direction: row no-wrap;
      -webkit-box-orient: horizontal;
      -webkit-box-direction: normal;
          flex-direction: row no-wrap;
  -ms-flex-pack: end;
      -webkit-box-pack: end;
          justify-content: flex-end;
  -ms-flex-align: center;
      -webkit-box-align: center;
          align-items: center;
}

.expression {
  font-size: 12px;
}

#screenRow2 {
  height: 35px;
  margin: 3px;
  padding: 0;
  -ms-flex-direction: row no-wrap;
      -webkit-box-orient: horizontal;
      -webkit-box-direction: normal;
          flex-direction: row no-wrap;
  -ms-flex-align: end;
      -webkit-box-align: end;
          align-items: flex-end;
}

.total {
  color: #3f3f3f;
  text-shadow: .5px .8px 2px rgba(0,0,0,.5);
  -ms-flex: 0 100%;
      -webkit-box-flex: 0;
          flex: 0 0 100%;
  margin: 0;
  padding: 0;
  text-align: right;
}

input[type=button] {
  border: none;
  outline: none;
  cursor: default;
  text-decoration: none;
  height: 40px;
  -ms-flex: 0 0 40px;
      -webkit-box-flex: 0;
          flex: 0 0 40px;
  border-radius: 2px;
  background-color: #f4f1d6; /*default*/
  margin: 0 .5px;
  -webkit-box-sizing: border-box;
          box-sizing: border-box;
  -webkit-box-shadow: 1px 0 1px .5px rgba(150,150,150,1);
          box-shadow: 1px 0 1px .5px rgba(150,150,150,1);
  line-height: 39px;
  text-align: center;
  font-weight: 700;
  font-size: 24px;
  text-shadow: 1px .8px 2px rgba(100,100,100,.8);
  color: #f25d49;
  background-image: radial-gradient(circle at center left,   
                    #f4f1d6, 
                    #d2d0b4
                    );
}

input[type=button]:active {
  -webkit-box-shadow: inset .5px .5px .5px rgba(0,0,0,.5);
          box-shadow: inset .5px .5px .5px rgba(0,0,0,.5);
  font-size: 22.5px;
}

#divide, 
#multiply,
#minus, 
#plus {
  color: #42282e;
}

#multiply  {
  line-height: 47px;
}

#minus {
  line-height: 35px;
}

#allClear {
  font-size: 20px;
  background-color: #f25d49; /*default*/
  color: #f4f1d6;
  background-image: radial-gradient(circle at center left,  
                    #f25d49, 
                    #d02a14
                    );
}

#clear {
  font-size: 20px;
  background-color: #f79962; /*default*/
  color: #f4f1d6;
  background-image: radial-gradient(circle at center left,      
                    #f79962, 
                    #f26c27
                    );
}

#equals {
  width: 164px;
  margin-left: 18px;
  background-color: #79b48d; /*default*/
  color: #f4f1d6;
  background-image: radial-gradient(circle at center left, 
                    #79b48d, 
                    #65928d
                    );
}

#allClear:active,
#clear:active {
  font-size: 19.5px;
}



              
            
!

JS

              
                //basic calculator knowledge is assumed, therefore no error handling applied
//does not take a negative number, but will output a negative total
!function() {
const stored = {
    operands: [],
    temp: [],
    total: document.querySelector('.total'),
    formula: document.querySelector('.expression')
};

function operator(documentItem) {                      
    documentItem.addEventListener('click', function() {
        const temp = parseFloat(stored.total.textContent); 
        stored.operands.push(temp);                  
        stored.formula.textContent += temp;          
        stored.formula.textContent += this.value;    
        stored.total.textContent = '';                
    });
} 

const buttons = {
    numBtns: document.querySelectorAll('.row input'),
    plusBtn: operator(document.querySelector('#plus')),
    subtractBtn: operator(document.querySelector('#minus')),
    divideBtn: operator(document.querySelector('#divide')),
    multiplyBtn: operator(document.querySelector('#multiply')),
    equalsBtn: document.querySelector('#equals').addEventListener('click', () => { 
               const temp2 = parseFloat(stored.total.textContent);
               stored.operands.push(temp2);                            
               stored.formula.textContent += stored.total.textContent; 
               stored.total.textContent = eval(stored.formula.textContent);    
               }),
  allClear: document.querySelector('#allClear').addEventListener('click', () => {        
            stored.total.textContent = '';
            stored.formula.textContent = '';
            stored.operands.length = 0;
            stored.temp.length = 0;
            }),
    clear: document.querySelector('#clear').onclick = () => {
           stored.temp.pop();
           stored.total.textContent = stored.temp[stored.temp.length - 1]; 
           }
};
  
for(let i = 0; i < buttons.numBtns.length; i++ ) {            
    buttons.numBtns[i].addEventListener('click', () => {
      const value = buttons.numBtns[i].value;
        if(parseFloat(buttons.numBtns[i].value) || buttons.numBtns[i].value === '0') {
            stored.total.textContent += value;            
            const temp = stored.total.textContent;  
            stored.temp.push(temp);
        }
    });
}
  
}();


              
            
!
999px

Console