Skip to main content

Best Ui Dark Calculator using Html,Css and Javascript

 

 How to Create a Calculator 


Introduction

Calculator is one of the basic projects of JavaScript or any other languages a newbie programmer should probably know how to create it.The best thing of this is that the coding is short and easy to understand. It is a basic project that perform arithmetical operations. All you have to do is to create a button for each number, arithmetic operations. symbols and then add a text-box or input-field.


Here is the Output of Dark Calculator:







Output:




Source Code:


Index.html:

Here is the html coding :)

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewportcontent="width=device-width, initial-scale=1.0">
<title>Dark Calculator</title>
<link rel="stylesheethref="styel.css">
</head>
<body>
<div class="main">
<div>
<input id="resulttype="text">
<button class="btnonclick="getNumber('1')">1</button>
<button class="btnonclick="getNumber('2')">2</button>
<button class="btnonclick="getNumber('3')">3</button>
<button class="btnonclick="getNumber('4')">4</button>
<button class="btnonclick="getNumber('5')">5</button>
<button class="btnonclick="getNumber('6')">6</button>
<button class="btnonclick="getNumber('7')">7</button>
<button class="btnonclick="getNumber('8')">8</button>
<button class="btnonclick="getNumber('9')">9</button>
<button class="btnonclick="getNumber('.')">.</button>
<button class="btnonclick="getNumber('0')">0</button>
<button class="btnonclick="getResult()">=</button>
</div>
<div>
<button class="clearonclick="clearResult()">C</button>
<button class="btnonclick="getNumber('+')">+</button>
<button class="btnonclick="getNumber('-')">-</button>
<button class="btnonclick="getNumber('*')">x</button>
<button class="btnonclick="getNumber('/')">/</button>
</div>
</div>
<h2 style=" font-family: Arial, Helvetica, sans-serif; text-decoration: underline; position: absolute; top: 20px;"> Created By:Arsalan Khan </h2>
</body>
<script src="app.js"></script>


Style.Css:

</html>


*{
    margin0padding0;
    border0outline0;
     box-sizingborder-box ;
     font-familysans-serif;

}
body{
    height100vh;
    displayflex;
    align-itemscenter;
    justify-contentcenter;
   background: rgb(223221224);
   

}
.main{
    displayflex;
    positionrelative;
    width300pxheight330px;
    padding30px;
    background#232424f6;
    border-radius:6px;
    box-shadow2px 9px 43px rgba(200.8);


}
.main input{
    margin6px 8px;
    width165pxheight42px;
    line-height40px;
    padding-left:12px;
    font-size18px;
    colorwhite;
    letter-spacing1px;
    backgroundtransparent;
    border-radius2px;
    border1px solid white;

}

.main button{
    cursorpointer;
    margin7px 7px;
    width42px ; height42px;
    font-size18px;
    backgroundtransparent;
    colorwhite;
    border-radius5px;
    border:1px solid white;
    transitionall .3s;

}
 .main button:hover{
     color#1d1c1c;
     backgroundwhite;
 }

App.js:


function getNumber(num){ //declaration of a function where as getNumber is our function name and within the round braces we passed argument//
  
    var result=document.getElementById("result");
    
    result.value +=num; //This is used for get number, and we used plus sign for concatination
    
    }
    function clearResult(){
        var result = document.getElementById("result"); //This is used for get element via 'id'
        result.value = "" //This empty string which is used to clear input field//
    }
    
    function getResult(){
        var result = document.getElementById("result"); 
        result.value=eval(result.value)
    }





Comments

Popular posts from this blog

Best ToDo-Application using javascript

To Do Application  What is To Do List? ToDoList is a type of software which is used for managing your productive workflow.It is also called "Getting things done" (GTD), scheduling and collaboration. ToDoList is general-purpose, Windows-based software, which can be used for simple “honey do” home lists or to manage complex multi-user projects for business. In addition to tracking the status of tasks, ToDoList includes a powerful system for logging and reporting time spent on tasks. Combined with powerful reporting mechanisms, this makes ToDoList an effective tool for client billing. About My To Do Application So as you can read the above intro of ToDO-Application, I build this with very easy way and you can also try this for enhance or revise your JavaScript concepts. The code is simple and easy to understand, if you are new to JavaScript and web development then this tutorial is for you.I tried my best to design it for user friendly and keep it simple.Here is some screen sh

Login & Signup forms using Html & CSS

  Login /Signup Form  Using Html & CSS Hello hope you all are fine :-), today I'm going to make Login and signup form by using html & css it is very easy to create just like a piece of cake! Login Form Index.Html <!DOCTYPE   html > <html   lang = "en" >      <head>      <meta   charset = "UTF-8" >      <meta   name = "viewport"   content = "width=device-width, initial-scale=1.0" >      <title> Join-Us </title>          <link   rel = "stylesheet"   href = "join-us.css" >     </head> <body>    <div   class = "form" >      <h1> Login  <span><hr   style = "  border: 0;       height: 1px;              background: rgb(129, 133, 131);padding-top:2px;       background-image: linear-gradient(to right, rgba(122, 184, 93, 0.678), rgba(135, 172, 141, 0.404), rgba(202, 200, 200, 0.521)); " ></span></h1>