Apple Calculator | Apple Developer Forums
Apple Calculator Safari & Web General HTML CSS JavaScript You’re now watching this thread. If you’ve opted in to email or web notifications, you’ll be notified when there’s activity. Click again to stop watching or visit your profile to manage watched threads and notifications. You’ve stopped watching this thread and will no longer receive emails or web notifications when there’s activity. Click again to start watching.
Tumbleweed2026 OP Created 2w Replies 1 Boosts 0 Views 842 Participants 2 Hello. I'm using Sololearn and ChatGPT to learn how to code. I've made a calculator before, but I want to make one similar to the one on iPhone. Is ok to have a link to apple.com or do I say I was inspired by Apple Here is the code I currently have: HTML <!DOCTYPE html> <html> <head> <title>Page Title</title> <meta name="viewport" content="width=device-width, initial-scale=1"> </head> <body> <div class="calculator"> <input class="display" type="text"> <div class = "scientific"> <button>(</button> <button>)</button> <button>mc</button> <button>m+</button> <button>m-</button> <button>mr</button> </div> <div class ="standard"> <button class="utility" id="backspace">⌫</button> <button class="utility" id="clear">AC</button> <button class="utility" id="percent">%</button> <button class="operator">/</button> <button class="number digit">7</button> <button class="number digit">8</button> <button class="number digit">9</button> <button class="operator">*</button> <button class="number digit">4</button> <button class="number digit">5</button> <button class="number digit">6</button> <button class="operator">-</button> <button class="number digit">1</button> <button class="number digit">2</button> <button class="number digit">3</button> <button class="operator">+</button> <button class="number" id="plusmn"><sup>+</sup>⁄<sub>-</sub></button> <button class="number digit">0</button> <button class="number" id="decimal">.</button> <button class="utility equals" id="equals">=</button> </div> </div> </body> </html> ``` ``` CSS body{ background-color: black; } html, body { margin: 0; width: 100%; height: 100%; background-color: black; } input { font-size: 48px; box-sizing: border-box; width: 100%; } .utility { background-color: #666; color: white; } .operator { background-color: orange; color: white; } .equals{ background-color: orange; color: white; } .number{ background-color: #333; color: white; } .calculator { display: grid; /*grid-template-columns: repeat(4, 1fr);*/ grid-template-columns: 1fr; gap: 4px; width: 100%; box-sizing: border-box; padding: 12px; position: fixed; bottom: 0; left: 0; } .calculator button { width: 100%; aspect-ratio: 1; border: none; border-radius: 50%; font-size: 32px; } .scientific{ display: grid; grid-template-columns: repeat(6, 1fr); gap: 4px; } .standard{ display: grid; grid-template-columns: repeat(4, 1fr); gap: 4px; } .display { color: white; background-color: black; border: none; height: 100px; font-size: 48px; text-align: right; box-sizing: border-box; width: 100%; } /* .display { grid-column: 1 / -1; color: white; background-color: black; border: none; height: 100px; font-size: 48px; text-align: right; box-sizing: border-box; width: 100%; } */ /* .zero { grid-column: span 2; border-radius: 40px; aspect-ratio: auto; } .calculator button.zero { aspect-ratio: auto; border-radius: 40px; } */ JS const display = document.querySelector(".display"); let fontSize = 48; function adjustFontSize() { fontSize = 48 - display.value.length * .99; if (fontSize < 20) { fontSize = 20; } display.style.fontSize = fontSize + "px"; } const buttonsJS = document.querySelectorAll(".digit"); buttonsJS.forEach(function(buttonJS) { buttonJS.addEventListener("click", function() { display.value += buttonJS.textContent; adjustFontSize(); }); }); const clear = document.querySelector("#clear"); clear.addEventListener("click", function() { display.value = ""; adjustFontSize(); }); const backspace = document.querySelector("#backspace"); backspace.addEventListener("click", function() { display.value = display.value.slice (0, -1); adjustFontSize(); }); const percent = document.querySelector("#percent"); percent.addEventListener("click", function(){ display.value /= 100; adjustFontSize(); }); const plusmn = document.querySelector("#plusmn"); plusmn.addEventListener("click", function(){ display.value /= -1; adjustFontSize(); }); const decimal = document.querySelector("#decimal"); decimal.addEventListener("click", function(){ if (!display.value.includes(".")) { display.value += "."; // Add the decimal point here } adjustFontSize(); }); const operators = document.querySelectorAll(".operator"); operators.forEach(function(operator) { operator.addEventListener("click", function() { display.value += operator.textContent; adjustFontSize(); }); }); const equals = document.querySelector("#equals"); equals.addEventListener("click", function() { display.value = eval(display.value); adjustFontSize(); }); /* const display = document.querySelector(".display"); const buttonJS = document.querySelector(".digit"); buttonJS.addEventListener("click", function() { console.log("You clicked the button!"); }); const buttonsJS = document.querySelectorAll(".digit"); buttonsJS.forEach(function(buttonJS) { buttonJS.addEventListener("click", function() { display.value += buttonJS.textContent; }); }); */ Replies 1 Boosts 0 Views 842 Participants 2 Claude31 OP 2w Is ok to have a link to apple.com or do I say I was inspired by Apple IMHO, none of the two.
See guidelines 5.2.5 Apple Products: Don’t create an app that appears confusingly similar to an existing Apple product, interface (such as Finder), app (such as the App Store, iTunes Store, or Messages Add comment