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 is required to process package imports. If you need a different preprocessor remove all packages first.

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

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

              
                <div class = "container">
  <div id = "screen"></div>
  <div id = "buttons">
    <div class = "button buttonClick">1
    </div>
    <div class = "button buttonClick">2
    </div>
    <div class = "button buttonClick">3
    </div>
    <div class = "button buttonClick">*
    </div>
    <div class = "button buttonClick">4
    </div>
    <div class = "button buttonClick">5
    </div>
    <div class = "button buttonClick">6
    </div>
    <div class = "button buttonClick">/
    </div>
    <div class = "button buttonClick">7
    </div>
    <div class = "button buttonClick">8
    </div>
    <div class = "button buttonClick">9
    </div>
    <div class = "button buttonClick">-
    </div>
    <div class = "button buttonClick">0
    </div>
    <div class = "button buttonClick">+
    </div> 
    <div class = "button buttonEnter">=
    </div>
    <div class = "button buttonClear">C
    </div>
  </div>
</div>
              
            
!

CSS

              
                /* brown = #331A1A;
WHEN MORE THAN 20 NUMBERS ARE TYPED I NEED TO DO SOMETHING TO SHOW THE NUMBERS
AND I NEED TO PREVENT THE USE OF ++++ --- MULTIPLE OPERATORS NEXT TO EACH OTHER
*/

body {
  background: lightblue  url("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAoAAAAKCAYAAACNMs+9AAAATElEQVQYV2O0O3X+PwMQHDIzZATRuAAj0QqxmfDghh3YFgWNQ3BbsFpHtEJstjBWnIdY02GIsIYyhdh0f5oZB7aFL30Rfs8QrRCbLQDvfSALXdnbSgAAAABJRU5ErkJggg=="); 
  text-align: center;
  
}

.container{
  width: 320px;
  height: 450px;
  display: inline-block;
  position: relative;
  top: 50px;
  border-radius: 10px;
  border: 4px solid rgb(0, 170, 150);
  box-shadow: 0px 0px 15px 6px grey;
  /*USING GRADIENT GENERATOR*/
  -webkit-box-sizing: content-box;
  -moz-box-sizing: content-box;
  box-sizing: content-box;
  font: normal 100%/normal Arial, Helvetica, sans-serif;
  color: rgba(255,255,255,1);
  -o-text-overflow: clip;
  text-overflow: clip;
  background: -webkit-linear-gradient(90deg, rgba(255,255,255,0.2) 50%, rgba(0,0,0,0) 50%, rgba(0,0,0,0) 0), rgb(0, 170, 238);
  background: -moz-linear-gradient(0deg, rgba(255,255,255,0.2) 50%, rgba(0,0,0,0) 50%, rgba(0,0,0,0) 0), rgb(0, 170, 238);
  background: linear-gradient(0deg, rgba(255,255,255,0.2) 50%, rgba(0,0,0,0) 50%, rgba(0,0,0,0) 0), rgb(0, 170, 238);
  background-position: auto auto;
  -webkit-background-origin: padding-box;
  background-origin: padding-box;
  -webkit-background-clip: border-box;
  background-clip: border-box;
  -webkit-background-size: 54px auto;
  background-size: 54px auto; 

}

#screen {
  width: 100%;
  height: 100px;
  background: white;
  margin: 10px auto;
  color: black;
  box-shadow: 0px 0px 15px 6px grey;
  font-size: 30px;
  line-height: 60px;
  
}

#buttons{
  margin: 0 auto;
  width: 100%;
  height: 250px;
  display: flex;
  flex-wrap: wrap;
  flex-direction: row;
  justify-content: space-around;
  align-items: center;
  cursor: pointer;

  
}

.button{
  width: 50px;
  height: 50px;
  margin: 10px;
  background: lightblue;
  box-shadow: 0px 0px 15px 3px grey;
  text-align: center;
  line-height: 45px;
  font-size: 30px;
  color: #364758;
  transition: all .2s;
}
.button:active{
  background: #5ba5ba;
  box-shadow: 0px 0px 5px 1px grey;
  height: 47px;
}

.button.buttonEnter {
  width: 125px;
}
.button.buttonClear{
  width: 100%;
  height: 30px;
  font-size: 20px;
  line-height: 30px;
}


              
            
!

JS

              
                //CACHING THE DOM

var buttons = document.getElementById("buttons");
//console.log(buttons);
var screen = document.getElementById("screen");
//console.log(screen);
var buttonEnter = document.getElementsByClassName("buttonEnter");
//console.log(buttonEnter);
var buttonClear =
document.getElementsByClassName("buttonClear");
var symbols = buttons.getElementsByClassName("buttonClick");
//console.log(symbols[0].innerHTML);TO TEST IF THE BUTTONS ARE WORKING
//console.log(symbols.length);CHECKING THE LENGTH



for(var i = 0; i < symbols.length; i++){
  symbols[i].addEventListener("click", append);
 buttonEnter[0].addEventListener("click",calculate);
  buttonClear[0].addEventListener("click",clear);

};







//ALL THE FUNCTIONS

function append(){
  
//.trim() is used to remove all the spaces between and before appending...It is always better to use .trim() any time something is added

  var screenVal = this.innerHTML.trim();
  screen.innerHTML +=screenVal;
  
}

function calculate(){
 //parseFloat will try to parse a string for a floating point number. It won't do anything with the operators. For example, parseFloat("2+3") will return 2 (It stops when it reaches the +)
  
var result = eval(screen.innerHTML);
  //console.log(result);
  screen.innerHTML = result;
}

function clear(){
  screen.innerHTML = "";
}
              
            
!
999px

Console