Calculator
HTML CODE:-
<!DOCTYPE html> <html> <head> <meta charset="utf-8"> <meta name="viewport" content="width=device-width, initial-scale=1"> <title></title> </head> <body> <div class="container"> <form> <div class="display"> <input type="text" name="dis"> </div> <div> <input type="button" class="btn" value="AC" onclick="dis.value = '' "> <input type="button" class="btn" value="DE" onclick="dis.value = dis.value.toString().slice(0,-1) "> <input type="button" class="btn" value="." onclick="dis.value += '.' "> <input type="button" class="btn" value="/" onclick="dis.value += '/' "> </div> <div> <input type="button" class="btn" value="7" onclick="dis.value += '7' "> <input type="button" class="btn" value="8" onclick="dis.value += '8' "> <input type="button" class="btn" value="9" onclick="dis.value += '9' "> <input type="button" class="btn" value="*" onclick="dis.value += '*' "> </div> <div> <input type="button" class="btn" value="4" onclick="dis.value += '4' "> <input type="button" class="btn" value="5" onclick="dis.value += '5' "> <input type="button" class="btn" value="6" onclick="dis.value += '6' "> <input type="button" class="btn" value="-" onclick="dis.value += '-' "> </div> <div> <input type="button" class="btn" value="1" onclick="dis.value += '1' "> <input type="button" class="btn" value="2" onclick="dis.value += '2' "> <input type="button" class="btn" value="3" onclick="dis.value += '3' "> <input type="button" class="btn" value="+" onclick="dis.value += '+' "> </div> <div> <input type="button" class="btn" value="00" onclick="dis.value += '00' "> <input type="button" class="btn" value="0" onclick="dis.value += '0' "> <input type="button" class="btn" value="=" onclick="dis.value = eval(dis.value)"> </div> </form> </div> </body> </html> |
CSS CODE:-
body{ padding: 0px; margin: 0px; display: flex; align-items: center; justify-content: center; min-height: 100vh; background-color: black; } .container{ background-color: #3a4452; border-radius: 10px; padding: 20px; } .display input{ width: 100%; text-align: right; font-size: 20px; margin: 10px 0; } .btn{ width: 40px; height: 40px; border: 0; outline: 0; border-radius: 10px; background-color: transparent; font-size: 20px; color: white; cursor: pointer; margin: 10px; box-shadow: rgba(0, 0, 0, 0.35) 0px 5px 15px; } |