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

              
                <html>
    <head>
        <meta charset="utf-8">
        <title> Hey </title>
        <link rel="stylesheet" href="main2.css">
        <link href="https://fonts.googleapis.com/css?family=Lato|Saira" rel="stylesheet">
    </head>

        <body>


 <div class="container">

            <div class="line">
                <button id="key" type="button" value="" name="button"> C </button>
                <div class="box" id="answer2" type="text" name="" value="" maxlength="10" > </div>
            </div>

        <div class="line2">
                <button class="button" type="button" value= "7" name="button"> 7 </button>
                <button class="button" type="button" value= "8" name="button"> 8 </button>
                <button class="button" type="button" value= "9" name="button"> 9 </button>
                <button class="button" id="bnt1" type="button" value= "/" name="button"> / </button>

        </div>

         <div class="line2">

                <button class="button" type="button" value= "4" name="button"> 4 </button>
                <button class="button" type="button" value= "5" name="button"> 5 </button>
                <button class="button" type="button" value= "6" name="button"> 6 </button>
                <button class="button" id="bnt2" type="button" value= "*"name="button"> X </button>
        </div>

        <div class="line2">

                <button class="button" type="button" value= "1" name="button"> 1 </button>
                <button class="button" type="button" value= "2" name="button"> 2 </button>
                <button class="button" type="button" value= "3" name="button"> 3 </button>
                <button class="button" id="bnt3" type="button" value= "-"name="button"> - </button>
        </div>
        <div class="line2">

                <button class="button"type="button" value= "0" name="button"> 0 </button>
                <button class="button" type="button" value= "." name="button"> . </button>
                <button class="equal" type="button" value= "=" name="button"> = </button>
                <button class="button" id="bnt3" type="button" value= "+"name="button"> + </button>
        </div>
 </div>

        <script src="main.js"></script>

        </body>
</html>
              
            
!

CSS

              
                
h1 {
    color:brown;
    font-family:
    text-align:center;

}

body {
    margin-left: 350px;
    margin-right: 300px;
    background-image: url());
    background-size: 1380px 1180px;
    margin-top: 180px;
    background-repeat: no-repeat;
    border: 5px

}

button {
    background-color: #FF5325;
    border-radius: 8px;
    color: white;
    padding: 30px;
    text-align: center;
    font-size: 16px;
    margin: 3px;
    font-family: 'Saira', sans-serif;

}

.box {
    border: 4px solid #FF5325;

}


#answer2{
    padding: 22px;
    width:180px;
    margin: 5px;
    font-size: 25px;
    border: 3px solid #FFB991;
    border-radius: 8px;
    text-align: right;
    color:white;
    font-family: 'Saira', sans-serif;
    background-color: #FFB991

}

#bnt1,#bnt2,#bnt3,#bnt4 {
    background-color: #FFA25D;
    /*border: none;*/
    border-radius: 10px;
    color: white;
    padding: 30px;
    text-align: center;
    font-size: 16px;

}

.line {
    display: flex;
    flex-direction: row;
    justify-content: space-around;
}


.container {
    background: white;
    border: 6px solid #FFA25D;
    width: 328px;
    border-radius: 8px;
}


.line2 {
    display: flex;
    justify-content: space-around;
}

              
            
!

JS

              
                

/// select button for show up answer ///
let answer = document.getElementById("answer2")
/// select the button of number and operater beside equal ///
let button = document.querySelectorAll(".button")
/// select eqaul button to do the math calulation ///
let equal = document.querySelector(".equal")
/// select C button to do clear value ///
let empty = document.getElementById("key")

// set up string for storage the button value, so they get call in other function //
let result = ""

empty.addEventListener("click", function(){
    let zero = " "
    answer.innerHTML = zero;

})


///////// create the loop to let them get in result string, then do the math//////////
for (let i = 0; i < button.length; i++) {
  button[i].addEventListener("click", function(){
  result += this.value
  answer.innerHTML = result;
});
}

//// when the equal button click, do th math use eval function ///
equal.addEventListener("click",function(){
    let sum = eval(result)
    answer.innerHTML = sum;
    console.log(sum)
    result = ""
})

////////after get the result, press "c" button to clear the textbox ///////
empty.addEventListener("click", function(){
    result = ""
    answer.innerHTML = result
    console.log("click")

})


//// limited /////

              
            
!
999px

Console