Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add: calculator using html css #142

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions Calculator/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# Calculator
made using simple html and css
74 changes: 74 additions & 0 deletions Calculator/assets/styles.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
* {
margin: 0;
padding: 0;
box-sizing: border-box;
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, 'Open Sans', 'Helvetica Neue', sans-serif;
}

body {
display: flex;
justify-content: center;
align-items: center;
min-height: 100vh;
background-color: darkgreen;
}

.calculator {
position: relative;
display: grid;
}

.calculator .values {
grid-column: span 4;
height: 100px;
text-align: right;
border: none;
outline: none;
padding: 10px;
font-size: 20px ;
}

.calculator span {
display: grid;
place-items: center;
width: 61px;
height: 61px;
color: whitesmoke;
font-weight: bold;
background-color: lightgreen;
border: 1px solid rgba(24, 114, 6, 0.5);
cursor: pointer;
}

.calculator span:hover {
background-color: blue;
color: yellow;
}

.calculator span:active {
background-color: darkblue;
}

.calculator span.clear {
grid-column: span 2;
width: 122px;
background-color: tomato;
}

.calculator span.equals {
grid-column: span 2;
width: 122px;
background-color: #03b1ff;
}

@media (min-width: 600px) {
span {
font-size: 1.25rem;
}
}

@media (min-width: 800px) {
span {
font-size: 1.5rem;
}
}
30 changes: 30 additions & 0 deletions Calculator/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
<!DOCTYPE html>
<html lang = "en">
<head>
<title>Calculator</title>
<link rel = "stylesheet" href = "./assets/styles.css">
</head>
<body>
<form class = "calculator" name = "calc">
<input class = "values" type = "text" name = "txt" readonly = "">
<span class = "clear" onclick = "document.calc.txt.value = ''">C</span>
<span onclick = "document.calc.txt.value += '00'">00</span>
<span onclick = "document.calc.txt.value += '/'">/</span>
<span onclick = "document.calc.txt.value += '7'">7</span>
<span onclick = "document.calc.txt.value += '8'">8</span>
<span onclick = "document.calc.txt.value += '9'">9</span>
<span onclick = "document.calc.txt.value += '*'">*</span>
<span onclick = "document.calc.txt.value += '4'">4</span>
<span onclick = "document.calc.txt.value += '5'">5</span>
<span onclick = "document.calc.txt.value += '6'">6</span>
<span onclick = "document.calc.txt.value += '+'">+</span>
<span onclick = "document.calc.txt.value += '1'">1</span>
<span onclick = "document.calc.txt.value += '2'">2</span>
<span onclick = "document.calc.txt.value += '3'">3</span>
<span onclick = "document.calc.txt.value += '-'">-</span>
<span onclick = "document.calc.txt.value += '0'">0</span>
<span onclick = "document.calc.txt.value += '.'">.</span>
<span class = "equals" onclick = "document.calc.txt.value = eval(calc.txt.value)">=</span>
</form>
</body>
</html>