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.

            
              <div class="container ">
  <div class="row">
    <span id="input" class="animated fadeInDownBig"></span> 
  </div>
  <div class="row" id="button-background">
    <div class="row animated fadeInUpBig"
         style="animation-delay: 100ms;">
      <span><a class="waves-effect waves-light btn red">C</a></span>
      <span><a class="waves-effect waves-light btn grey darken-4">%</a></span>
      <span><a class="waves-effect waves-light btn  grey darken-4">!</a></span>
      <span><a class="waves-effect waves-light btn  grey darken-4">&#960</a></span>
    </div>
    <div class="row animated fadeInUpBig"
         style="animation-delay: 200ms;">
      <span><a class="waves-effect waves-light btn">7</a></span>
      <span><a class="waves-effect waves-light btn">8</a></span>
      <span><a class="waves-effect waves-light btn">9</a></span>
      <span><a class="waves-effect waves-light btn  grey darken-4">+</a></span></div>
    <div class="row animated fadeInUpBig"
         style="animation-delay: 300ms;">
      <span><a class="waves-effect waves-light btn">4</a></span>
      <span><a class="waves-effect waves-light btn">5</a></span>
      <span><a class="waves-effect waves-light btn">6</a></span>
      <span><a class="waves-effect waves-light btn  grey darken-4">-</a></span>
    </div>
    <div class="row animated fadeInUpBig"
         style="animation-delay:  400ms;">
      <span><a class="waves-effect waves-light btn">1</a></span>
      <span><a class="waves-effect waves-light btn">2</a></span>
      <span><a class="waves-effect waves-light btn">3</a></span>
      <span><a class="waves-effect waves-light btn grey darken-4">÷</a></span>
    </div>
    <div class="row animated fadeInUpBig"
         style="animation-delay: 500ms;">
      <span><a class="waves-effect waves-light btn">0</a></span>
      <span><a class="waves-effect waves-light btn">.</a></span>
      <span><a class="waves-effect waves-light btn black">=</a></span>
      <span><a class="waves-effect waves-light btn grey darken-4">x</a></span>
    </div>
  </div>
<p>by <strong>Suleyman Tekin</strong></p>
            
          
!
            
              * {
  margin: 0px;
  padding: 0;
  box-sizing: border-box;
  font-family: 'Roboto Mono', monospace;
}

body {
  background-color: #b0bec5;
  color: white; 
  -webkit-user-select: none; /* Chrome/Safari */        
  -moz-user-select: none; /* Firefox */
  -ms-user-select: none; /* IE10+ */
}

.container {
  width: 304px;
  height: 617px;
  background-image: url(https://www.mobicommerce.net/wp-content/uploads/2017/03/phone_1x.png);
/*  background-repeat: no-repeat;
  background-size: contain;
  */
  background-position: center;
  border-radius: 40px;
  background-color: #004d40;
  box-shadow: -1px 0 0 #004d40;

}

#input {
  color: white;
  position: absolute;
  margin: 120px 0px 0px 11px;
  width: 304px;
  font-size: 20px;
  height: 150px;
  padding: 20px 20px;
  background: black;
  overflow: hidden;
  user-select: none;
}



#button-background{
  padding: 270px 0px 0px 31px;
}

@media screen and (min-width: 990px) {
  #button-background {
    padding-left:26px;

  }
  
}

@media screen and (min-width: 1200px) {
  #button-background {
    padding-left:21px;

  }
}
p{
  text-align:center;
  color: #424242;
}



            
          
!
            
              /*
 * By Suleyman Tekin
 */

var flag = false;
$("a").click(function() {
  switch ($(this).text()) {
    case ".":
    case "0":
    case "1":
    case "2":
    case "3":
    case "4":
    case "5":
    case "6":
    case "7":
    case "8":
    case "9":
      if(flag){$("#input").text("");}
      $("#input").append($(this).text());
      flag = false;
      break;
      
    case "-":
    case "+":
    case "÷":
    case "x":
    case "%":
      if (checkOperator()) {
        $("#input").append($(this).text());
        flag=false;
      }
      break;
      
    case "=":
      if (checkOperator()) {
        var inputResult = $("#input").text();
        inputResult = inputResult.replace(/÷/g, "/");
        inputResult = inputResult.replace(/x/g, "*");
        var result = eval(inputResult);
        $("#input").text(result);
        flag = true;
      }
      break;
      
    case "C":
      $("#input").text("");
      break;
      
    case 'π':
      var str = $("#input").text();
      var last = str[str.length - 1]
      if("-+x÷%".indexOf(last) != -1){
        $("#input").append("3.1415926535");
      }else{
        $("#input").text("3.1415926535");
      }
      flag = true;
      break;
      
    case '!':
      var str = $("#input").text()
          if(!/[\+\-x÷\%]/.test(str) && str.length != 0){
            $("#input").text(factorial(Number(str)));
            flag = true;
          }
      break;
  }
});

//Checks if the number is an operator if it is return true else false
function checkOperator() {
  var str = $("#input").text();
  var last = str[str.length - 1];
  var operators = "-+x÷%";
  if (operators.indexOf(last) == -1) {
    if (str.length == 0) {
      return false;
    }
    return true;
  }
  return false;
}


//Calculates the factoriel of the given number
function factorial (n) {
  var result = 1;
  if (n == 0 || n == 1){
    return 1;
  } else{
    for(var i = 1; i <= n; i++){
      result *= i;
    }
    return result;
  }
}
            
          
!
999px
Loading ..................

Console