Pages

Wednesday, 4 December 2024

Decimal to Binary Converter Tool



Decimal to Binary Converter

Decimal to Binary Converter

Binary Result:

0

/* Reset default styles */ * { margin: 0; padding: 0; box-sizing: border-box; } body { font-family: 'Poppins', sans-serif; background: linear-gradient(45deg, #6e7ccf, #8e44ad); display: flex; justify-content: center; align-items: center; height: 100vh; } .container { display: flex; justify-content: center; align-items: center; } .card { background-color: #fff; border-radius: 10px; padding: 30px; box-shadow: 0 5px 15px rgba(0, 0, 0, 0.1); text-align: center; width: 300px; } h1 { font-size: 1.8em; margin-bottom: 20px; color: #333; } input { width: 80%; padding: 10px; margin-bottom: 20px; border: 2px solid #6e7ccf; border-radius: 5px; font-size: 1em; color: #333; } input:focus { outline: none; border-color: #8e44ad; } button { width: 80%; padding: 10px; border: none; background-color: #8e44ad; color: white; font-size: 1em; border-radius: 5px; cursor: pointer; transition: background-color 0.3s ease; } button:hover { background-color: #6e7ccf; } .result { margin-top: 20px; } .result h2 { font-size: 1.2em; color: #333; } .result p { font-size: 1.5em; color: #8e44ad; font-weight: 600; } document.getElementById('convertBtn').addEventListener('click', function() { const decimalInput = document.getElementById('decimalInput').value; const binaryResult = document.getElementById('binaryResult'); if (decimalInput === "") { alert("Please enter a decimal number!"); return; } // Convert the decimal number to binary const binary = parseInt(decimalInput, 10).toString(2); binaryResult.textContent = binary; });