Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

simple working calculator updated#27

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Open
Gokulakrishnan5060 wants to merge1 commit intosahandghavidel:main
base:main
Choose a base branch
Loading
fromGokulakrishnan5060:gokulakrishnan_branch
Open
Show file tree
Hide file tree
Changes fromall 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
Binary file addedprojects/calculator/favicon.png
View file
Open in desktop
Loading
Sorry, something went wrong.Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
52 changes: 52 additions & 0 deletionsprojects/calculator/index.html
View file
Open in desktop
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
<!DOCTYPE html>
<html lang="en">
<head>
<!-- Meta tags -->
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta name="description" content="A simple calculator web application by Gokulakrishnan S">
<meta name="keywords" content="calculator, web application, math, arithmetic">
<meta name="author" content="Gokulakrishnan S">

<!-- Title -->
<title>Gokulakrishnan Calculator</title>

<!-- Stylesheet -->
<link rel="stylesheet" href="style.css">

<!-- Favicon -->
<link rel="shortcut icon" href="favicon.png" type="image/x-icon">
</head>
<body>
<div class="calculator">
<h1>G Calculator</h1>
<div class="display">
<input type="text" id="display" disabled>
</div>
<div class="keys">
<div class="operators">
<button class="operator" onclick="appendToDisplay('/')">/</button>
<button class="operator" onclick="appendToDisplay('*')">*</button>
<button class="operator" onclick="appendToDisplay('-')">-</button>
<button class="operator" onclick="appendToDisplay('+')">+</button>
</div>
<div class="numbers">
<button class="number" onclick="appendToDisplay('7')">7</button>
<button class="number" onclick="appendToDisplay('8')">8</button>
<button class="number" onclick="appendToDisplay('9')">9</button>
<button class="number" onclick="appendToDisplay('4')">4</button>
<button class="number" onclick="appendToDisplay('5')">5</button>
<button class="number" onclick="appendToDisplay('6')">6</button>
<button class="number" onclick="appendToDisplay('1')">1</button>
<button class="number" onclick="appendToDisplay('2')">2</button>
<button class="number" onclick="appendToDisplay('3')">3</button>
<button class="number" onclick="appendToDisplay('0')">0</button>
<button class="number" onclick="appendToDisplay('.')">.</button>
<button class="clear" onclick="clearDisplay()">C</button>
<button class="calculate" onclick="calculate()">=</button>
</div>
</div>
</div>
<script src="script.js"></script>
</body>
</html>
22 changes: 22 additions & 0 deletionsprojects/calculator/script.js
View file
Open in desktop
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
let expression = '';

function appendToDisplay(value) {
expression += value;
document.getElementById('display').value = expression;
}

function calculate() {
try {
const result = eval(expression);
document.getElementById('display').value = result;
expression = '';
} catch (error) {
document.getElementById('display').value = 'Error';
expression = '';
}
}

function clearDisplay() {
expression = '';
document.getElementById('display').value = '';
}
84 changes: 84 additions & 0 deletionsprojects/calculator/style.css
View file
Open in desktop
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,84 @@
body {
margin: 0;
padding: 0;
font-family: Arial, sans-serif;
background: url("https://images.unsplash.com/photo-1625225233840-695456021cde?auto=format&fit=crop&q=80&w=1000&ixlib=rb-4.0.3&ixid=M3wxMjA3fDB8MHxzZWFyY2h8Mnx8Y2FsY3VsYXRlfGVufDB8fDB8fHww");
background-size: contain;
background-position: center;
display: flex;
justify-content: center;
align-items: center;
height: 100vh;
}

.calculator {
background-color: rgba(255, 255, 255, 0.8);
border-radius: 10px;
padding: 20px;
text-align: center;
box-shadow: 0 0 10px rgba(0, 0, 0, 0.2);
max-width: 300px;
margin: 0 auto;
}

h1 {
margin-top: 0;
}

.display {
margin-bottom: 20px;
}

input[type="text"] {
width: 100%;
padding: 10px;
font-size: 1.5em;
}

.keys {
display: flex;
flex-direction: column;
align-items: center;
}

button {
width: 60px;
height: 60px;
margin: 5px;
font-size: 1.2em;
border-radius: 5px;
border: none;
outline: none;
cursor: pointer;
transition: all 0.2s ease-in-out;
}

button:hover {
transform: scale(1.1);
}

.operator {
background-color: #ff847c;
color: white;
}

.number {
background-color: #70c1b3;
color: white;
}

.clear {
background-color: #b8b8b8;
color: white;
}

.calculate {
background-color: #f0c987;
color: white;
}

@media only screen and (max-width: 600px) {
.calculator {
max-width: 90%;
}
}

[8]ページ先頭

©2009-2025 Movatter.jp