Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <!DOCTYPE html>
- <html>
- <head>
- <title>Calculator By Goldnera</title>
- <link rel="stylesheet" type="text/css" href="style.css">
- </head>
- <body>
- <div class="calculator">
- <input type="text" id="result" readonly>
- <div class="keypad">
- <button onclick="clearResult()">C</button>
- <button onclick="appendToResult('/')">/</button>
- <button onclick="appendToResult('7')">7</button>
- <button onclick="appendToResult('8')">8</button>
- <button onclick="appendToResult('9')">9</button>
- <button onclick="appendToResult('*')">*</button>
- <button onclick="appendToResult('4')">4</button>
- <button onclick="appendToResult('5')">5</button>
- <button onclick="appendToResult('6')">6</button>
- <button onclick="appendToResult('-')">-</button>
- <button onclick="appendToResult('1')">1</button>
- <button onclick="appendToResult('2')">2</button>
- <button onclick="appendToResult('3')">3</button>
- <button onclick="appendToResult('+')">+</button>
- <button onclick="appendToResult('0')">0</button>
- <button onclick="calculateResult()">=</button>
- </div>
- </div>
- <script src="script.js"></script>
- </body>
- </html>
- <style>.calculator {
- width: 300px;
- margin: 0 auto;
- background-color: #f2f2f2;
- border-radius: 8px;
- box-shadow: 0px 0px 10px rgba(0, 0, 0, 0.1);
- padding: 20px;
- }
- input {
- width: 100%;
- height: 50px;
- font-size: 24px;
- padding: 10px;
- border: none;
- border-radius: 4px;
- margin-bottom: 20px;
- }
- .keypad {
- display: grid;
- grid-template-columns: repeat(4, 1fr);
- grid-gap: 10px;
- }
- button {
- width: 100%;
- height: 60px;
- font-size: 24px;
- border: none;
- border-radius: 4px;
- background-color: #e0e0e0;
- color: #333333;
- cursor: pointer;
- transition: background-color 0.3s ease;
- }
- button:hover {
- background-color: #cccccc;
- }
- .clear {
- grid-column: 1 / span 2;
- }
- .zero {
- grid-column: 1 / span 2;
- }
- </style>
- <script>function clearResult() { // To Open his file, save it and open it
- document.getElementById("result").value = "";
- }
- function appendToResult(value) {
- document.getElementById("result").value += value;
- }
- function calculateResult() {
- var result = document.getElementById("result").value;
- var calculatedResult = eval(result);
- document.getElementById("result").value = calculatedResult;
- }
- </script>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement