<!DOCTYPE html>
<html> <head> <title>Decimal to Binary Converter</title> <style> body { font-family: Arial, sans-serif; background-color: #f2f2f2; } .container { display: flex; flex-direction: column; align-items: center; margin-top: 100px; } h1 { color: #333; margin-bottom: 20px; } .text-area { width: 400px; height: 200px; padding: 10px; border: 2px solid #ccc; border-radius: 4px; resize: none; } .convert-button { padding: 10px 20px; font-size: 16px; font-weight: bold; color: #fff; background-color: #4CAF50; border: none; border-radius: 4px; cursor: pointer; } .convert-button:hover { background-color: #45a049; } .result { margin-top: 20px; font-size: 18px; font-weight: bold; color: #333; white-space: pre-wrap; } @media screen and (max-width: 480px) { .text-area { width: 250px; } } </style> </head> <body> <div class="container"> <h1>Decimal to Binary Converter</h1> <textarea id="inputDecimal" class="text-area" placeholder="Enter decimal number"></textarea> <button onclick="convertToBinary()" class="convert-button">Convert</button> <div id="result" class="result"></div> </div> <script> function convertToBinary() { var inputDecimal = document.getElementById("inputDecimal").value; var decimal = parseInt(inputDecimal); var binary = decimal.toString(2); document.getElementById("result").textContent = "Binary representation: " + binary; } </script> </body> </html>
Comments
Post a Comment
sunil191280@gmail.com