diff --git a/calculator/index.html b/calculator/index.html new file mode 100644 index 0000000..fc01488 --- /dev/null +++ b/calculator/index.html @@ -0,0 +1,46 @@ + + + + + + + Calculator + + +
+ +
+ + + + +
+
+ + + + +
+
+ + + + +
+
+ + + + +
+
+ + + + +
+
+ + + + \ No newline at end of file diff --git a/calculator/main.js b/calculator/main.js new file mode 100644 index 0000000..071454e --- /dev/null +++ b/calculator/main.js @@ -0,0 +1,26 @@ +let input = document.getElementById("inputBox"); +let buttons = document.querySelectorAll("button"); + +let string = ""; +let arr = Array.from(buttons); + +arr.forEach(button => { + button.addEventListener('click', (e) => { + if(e.target.innerHTML == '='){ + string = eval(string); + input.value = string; + } + else if(e.target.innerHTML == 'AC'){ + string = ""; + input.value = string; + } + else if(e.target.innerHTML == 'DEL'){ + string = string.substring(0, string.length-1); + input.value = string; + } + else{ + string += e.target.innerHTML; + input.value = string; + } + }) +}) \ No newline at end of file diff --git a/calculator/style.css b/calculator/style.css new file mode 100644 index 0000000..7e8f963 --- /dev/null +++ b/calculator/style.css @@ -0,0 +1,63 @@ +@import url('https://fonts.googleapis.com/css2?family=Pacifico&family=Poppins:wght@500&family=Satisfy&display=swap'); + +*{ + margin: 0; + padding: 0; + box-sizing: border-box; + font-family: 'Poppins', sans-serif; +} + +body { + width: 100%; + height: 100vh; + display: flex; + justify-content: center; + align-items: center; + background: linear-gradient(45deg, #0a0a0a, #3a4442) +} + +.calculator{ + border: 1px solid #717377; + border-radius: 15px; + padding: 20px; + background: transparent; + box-shadow: 0px, 3px, 15px rgba(113, 115, 119, 0.5); +} + +input{ + width: 320px; + border: none; + padding: 24px; + margin: 10px; + background: transparent; + box-shadow: 0px 3px 15px rgba(84, 84, 84, 0.1); + font-size: 40px; + text-align: right; + cursor: pointer; + color: #ffffff; +} + +input::placeholder{ + color: #ffffff; +} + +button{ + width: 60px; + height: 60px; + border: none; + margin: 10px; + border-radius: 50%; + background: transparent; + color: #ffffff; + font-size: 20px; + box-shadow: -8px -8px 15px rgba(255, 255, 255, 0.1); + cursor: pointer; +} + +.equalButton{ + background-color: #fb7c14; +} + +.operator{ + color: #fb7c14; +} \ No newline at end of file