google.com, pub-8084589545867320, DIRECT, f08c47fec0942fa0 ALL AMAZING WEB TOOL: CLASS CALCULATOR

CLASS CALCULATOR

Colorful Calculator
body { display: flex; justify-content: center; align-items: center; height: 100vh; margin: 0; background-color: #f2f2f2; } .calculator { background-color: #444; border-radius: 10px; padding: 20px; box-shadow: 0px 4px 8px rgba(0, 0, 0, 0.2); width: 300px; text-align: center; } #display { width: 100%; padding: 10px; margin-bottom: 10px; font-size: 24px; background-color: #333; border: none; color: white; text-align: right; } .buttons { display: grid; grid-template-columns: repeat(4, 1fr); grid-gap: 10px; } button { padding: 15px; font-size: 20px; background-color: #666; border: none; color: white; cursor: pointer; border-radius: 5px; transition: background-color 0.3s; } button:hover { background-color: #555; } .operator { background-color: #ff9500; } .zero { grid-column: span 2; } document.addEventListener("DOMContentLoaded", function () { const display = document.getElementById("display"); const buttons = document.querySelectorAll("button"); buttons.forEach(button => { button.addEventListener("click", function () { if (this.textContent === "C") { display.value = ""; } else if (this.textContent === "=") { try { display.value = eval(display.value); } catch (error) { display.value = "Error"; } } else { display.value += this.textContent; } }); }); });

No comments:

Post a Comment