show-notice
hide-notice

Saturday, 7 September 2013

Create a Simple and Stylish Calculator Using HTML, CSS and JavaScript


Introduction:

Here i will explain Create a Simple and Stylish Calculator Using HTML, CSS and JavaScript.

Description:

In this article, we will create a calculator step-by-step. We need to create a basic structure using HTML, style it using CSS and make it work using JavaScript.

HTML:

CSS:
body
{
background-color:tan;
}
.box
{
background-color:#3d4543;
height:300px;
width:250px;
border-radius:10px;
position:relative;
top:80px;
left:40%;
}
.display
{
background-color:#222;
width:220px;
position:relative;
left:15px;
top:20px;
height:40px;
}
.display input
{
position:relative;
left:2px;
top:2px;
height:35px;
color:black;
background-color:#bccd95;
font-size:21px;
text-align:right;
}
.keys {
position:relative;
top:15px;
}
.button {
width:40px;
height:30px;
border:none;
border-radius:8px;
margin-left:17px;
cursor:pointer;
border-top:2px solid transparent;
}
.button.gray {
color:white;
background-color:#6f6f6f;
border-bottom:black 2px solid;
border-top:2px #6f6f6f solid;
}
.button.pink {
color:black;
background-color:#ff4561;
border-bottom:black 2px solid;
}
.button.black {
color:white;
background-color:303030;
border-bottom:black 2px solid;
border-top:2px 303030 solid;
}
.button.orange {
color:black;
background-color:FF9933;
border-bottom:black 2px solid;
border-top:2px FF9933 solid;
}
.gray:active {
border-top:black 2px solid;
border-bottom:2px #6f6f6f solid;
}
.pink:active {
border-top:black 2px solid;
border-bottom:#ff4561 2px solid;
}
.black:active {
border-top:black 2px solid;
border-bottom:#303030 2px solid;
}
.orange:active {
border-top:black 2px solid;
border-bottom:FF9933 2px solid;
}
p {
line-height:10px;
}
SCRIPT:
function c(val)
{
 document.getElementById("d").value=val;
}
    function v(val)
{document.getElementById("d").value+=val;
}
function e() 
{ 
    try 
    { 
        c(eval(document.getElementById("d").value)) 
    } 
    catch(e) 
    {
        c('Error') } 
}

SHARE THIS POST   

12 comments :

  1. Oh, never thought it was that simple!

    ReplyDelete
  2. JavaScript part didn't function, when I tried.

    ReplyDelete
  3. Please give me link to download zip directly..

    ReplyDelete
  4. please how to attach square root and trigonometry functions to the code, you can alert me on this gmail. malambakareabdul@gmail.com

    thanks

    ReplyDelete
  5. What you are spoken communication is totally true. i do know that everyone should say a similar factor, however I simply assume that you simply place it in an exceedingly method that everybody will perceive. i am positive you may reach such a lot of folks with what you've to mention.

    ReplyDelete
  6. Very attention-grabbing diary. lots of blogs I see recently do not extremely give something that attract others, however i am most positively fascinated by this one. simply thought that i'd post and allow you to apprehend.

    ReplyDelete
  7. David Walsh is Mozilla’s senior web developer, and the core developer for the MooTools Javascript Framework. David’s blog reflects his skills in HTML/5, JS and CSS, and offers a ton of engaging advice and insight into front-end technologies. Even more obvious is his passion for open source contribution and trial-and-error development, making his blog one of the most honest and engaging around.
    Website: davidwalsh.name

    ReplyDelete
  8. David Walsh is Mozilla’s senior web developer, and the core developer for the MooTools Javascript Framework. David’s blog reflects his skills in HTML/5, JS and CSS, and offers a ton of engaging advice and insight into front-end technologies. Even more obvious is his passion for open source contribution and trial-and-error development, making his blog one of the most honest and engaging around.
    Website: davidwalsh.name

    ReplyDelete
  9. David Walsh is Mozilla’s senior web developer, and the core developer for the MooTools Javascript Framework. David’s blog reflects his skills in HTML/5, JS and CSS, and offers a ton of engaging advice and insight into front-end technologies. Even more obvious is his passion for open source contribution and trial-and-error development, making his blog one of the most honest and engaging around.
    Website: davidwalsh.name

    ReplyDelete
  10. David Walsh is Mozilla’s senior web developer, and the core developer for the MooTools Javascript Framework. David’s blog reflects his skills in HTML/5, JS and CSS, and offers a ton of engaging advice and insight into front-end technologies. Even more obvious is his passion for open source contribution and trial-and-error development, making his blog one of the most honest and engaging around.
    Website: davidwalsh.name

    ReplyDelete
  11. David Walsh is Mozilla’s senior web developer, and the core developer for the MooTools Javascript Framework. David’s blog reflects his skills in HTML/5, JS and CSS, and offers a ton of engaging advice and insight into front-end technologies. Even more obvious is his passion for open source contribution and trial-and-error development, making his blog one of the most honest and engaging around.
    Website: davidwalsh.name

    ReplyDelete

Design by Gohilinfotech | www.gohilinfotech.blogspot.com