Spaces:
Running
Running
| <html lang="en"> | |
| <head> | |
| <meta charset="UTF-8"> | |
| <meta name="viewport" content="width=device-width, initial-scale=1.0"> | |
| <title>Number System Converter</title> | |
| <script src="https://cdn.tailwindcss.com"></script> | |
| <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.0/css/all.min.css"> | |
| <style> | |
| .gradient-bg { | |
| background: linear-gradient(135deg, #6e8efb, #a777e3); | |
| } | |
| .result-box { | |
| transition: all 0.3s ease; | |
| } | |
| .result-box:hover { | |
| transform: translateY(-5px); | |
| box-shadow: 0 10px 20px rgba(0,0,0,0.1); | |
| } | |
| .copy-btn { | |
| transition: all 0.2s ease; | |
| } | |
| .copy-btn:hover { | |
| background-color: rgba(255,255,255,0.2); | |
| } | |
| .copy-btn:active { | |
| transform: scale(0.95); | |
| } | |
| .pulse { | |
| animation: pulse 1.5s infinite; | |
| } | |
| @keyframes pulse { | |
| 0% { transform: scale(1); } | |
| 50% { transform: scale(1.05); } | |
| 100% { transform: scale(1); } | |
| } | |
| </style> | |
| </head> | |
| <body class="min-h-screen gradient-bg text-white"> | |
| <div class="container mx-auto px-4 py-12"> | |
| <div class="max-w-2xl mx-auto"> | |
| <div class="text-center mb-10"> | |
| <h1 class="text-4xl font-bold mb-2">Number System Converter</h1> | |
| <p class="text-lg opacity-90">Convert decimal numbers to binary, hexadecimal, and octal</p> | |
| </div> | |
| <div class="bg-white bg-opacity-10 backdrop-filter backdrop-blur-lg rounded-xl shadow-2xl p-6 mb-8"> | |
| <div class="flex items-center mb-6"> | |
| <div class="mr-4"> | |
| <i class="fas fa-exchange-alt text-2xl text-yellow-300"></i> | |
| </div> | |
| <div> | |
| <h2 class="text-xl font-semibold">Input Number</h2> | |
| <p class="text-sm opacity-80">Enter a decimal number to convert</p> | |
| </div> | |
| </div> | |
| <div class="relative"> | |
| <input | |
| type="number" | |
| id="decimalInput" | |
| placeholder="Enter decimal number" | |
| class="w-full bg-white bg-opacity-20 border border-white border-opacity-30 rounded-lg py-3 px-4 text-white placeholder-white placeholder-opacity-70 focus:outline-none focus:ring-2 focus:ring-yellow-300 focus:border-transparent" | |
| oninput="convertNumber()" | |
| > | |
| <button | |
| onclick="clearInput()" | |
| class="absolute right-3 top-1/2 transform -translate-y-1/2 text-white opacity-70 hover:opacity-100 transition-opacity" | |
| > | |
| <i class="fas fa-times"></i> | |
| </button> | |
| </div> | |
| </div> | |
| <div class="grid grid-cols-1 md:grid-cols-3 gap-4"> | |
| <!-- Binary Result --> | |
| <div class="result-box bg-white bg-opacity-10 backdrop-filter backdrop-blur-lg rounded-xl shadow-lg p-6"> | |
| <div class="flex justify-between items-center mb-4"> | |
| <div class="flex items-center"> | |
| <div class="w-10 h-10 rounded-full bg-blue-500 flex items-center justify-center mr-3"> | |
| <span class="font-mono font-bold">BIN</span> | |
| </div> | |
| <div> | |
| <h3 class="font-semibold">Binary</h3> | |
| <p class="text-xs opacity-70">Base 2</p> | |
| </div> | |
| </div> | |
| <button | |
| onclick="copyToClipboard('binaryResult')" | |
| class="copy-btn w-8 h-8 rounded-full bg-white bg-opacity-10 flex items-center justify-center hover:bg-opacity-20" | |
| title="Copy to clipboard" | |
| > | |
| <i class="fas fa-copy text-sm"></i> | |
| </button> | |
| </div> | |
| <div class="bg-black bg-opacity-30 rounded-lg p-3 font-mono overflow-x-auto"> | |
| <span id="binaryResult" class="text-yellow-300">-</span> | |
| </div> | |
| </div> | |
| <!-- Hexadecimal Result --> | |
| <div class="result-box bg-white bg-opacity-10 backdrop-filter backdrop-blur-lg rounded-xl shadow-lg p-6"> | |
| <div class="flex justify-between items-center mb-4"> | |
| <div class="flex items-center"> | |
| <div class="w-10 h-10 rounded-full bg-green-500 flex items-center justify-center mr-3"> | |
| <span class="font-mono font-bold">HEX</span> | |
| </div> | |
| <div> | |
| <h3 class="font-semibold">Hexadecimal</h3> | |
| <p class="text-xs opacity-70">Base 16</p> | |
| </div> | |
| </div> | |
| <button | |
| onclick="copyToClipboard('hexResult')" | |
| class="copy-btn w-8 h-8 rounded-full bg-white bg-opacity-10 flex items-center justify-center hover:bg-opacity-20" | |
| title="Copy to clipboard" | |
| > | |
| <i class="fas fa-copy text-sm"></i> | |
| </button> | |
| </div> | |
| <div class="bg-black bg-opacity-30 rounded-lg p-3 font-mono overflow-x-auto"> | |
| <span id="hexResult" class="text-yellow-300">-</span> | |
| </div> | |
| </div> | |
| <!-- Octal Result --> | |
| <div class="result-box bg-white bg-opacity-10 backdrop-filter backdrop-blur-lg rounded-xl shadow-lg p-6"> | |
| <div class="flex justify-between items-center mb-4"> | |
| <div class="flex items-center"> | |
| <div class="w-10 h-10 rounded-full bg-purple-500 flex items-center justify-center mr-3"> | |
| <span class="font-mono font-bold">OCT</span> | |
| </div> | |
| <div> | |
| <h3 class="font-semibold">Octal</h3> | |
| <p class="text-xs opacity-70">Base 8</p> | |
| </div> | |
| </div> | |
| <button | |
| onclick="copyToClipboard('octalResult')" | |
| class="copy-btn w-8 h-8 rounded-full bg-white bg-opacity-10 flex items-center justify-center hover:bg-opacity-20" | |
| title="Copy to clipboard" | |
| > | |
| <i class="fas fa-copy text-sm"></i> | |
| </button> | |
| </div> | |
| <div class="bg-black bg-opacity-30 rounded-lg p-3 font-mono overflow-x-auto"> | |
| <span id="octalResult" class="text-yellow-300">-</span> | |
| </div> | |
| </div> | |
| </div> | |
| <div class="mt-8 text-center text-sm opacity-80"> | |
| <p>Made with <i class="fas fa-heart text-red-400"></i> using HTML, CSS & JavaScript</p> | |
| </div> | |
| </div> | |
| </div> | |
| <script> | |
| function convertNumber() { | |
| const decimalInput = document.getElementById('decimalInput').value; | |
| if (decimalInput === '') { | |
| document.getElementById('binaryResult').textContent = '-'; | |
| document.getElementById('hexResult').textContent = '-'; | |
| document.getElementById('octalResult').textContent = '-'; | |
| return; | |
| } | |
| const decimalNumber = parseInt(decimalInput); | |
| // Binary conversion | |
| const binary = decimalNumber.toString(2); | |
| document.getElementById('binaryResult').textContent = binary; | |
| // Hexadecimal conversion | |
| const hex = decimalNumber.toString(16).toUpperCase(); | |
| document.getElementById('hexResult').textContent = `0x${hex}`; | |
| // Octal conversion | |
| const octal = decimalNumber.toString(8); | |
| document.getElementById('octalResult').textContent = `0${octal}`; | |
| } | |
| function clearInput() { | |
| document.getElementById('decimalInput').value = ''; | |
| convertNumber(); | |
| document.getElementById('decimalInput').focus(); | |
| } | |
| function copyToClipboard(elementId) { | |
| const element = document.getElementById(elementId); | |
| const text = element.textContent; | |
| if (text === '-') return; | |
| navigator.clipboard.writeText(text.replace(/^0x|^0/, '')); | |
| // Visual feedback | |
| const originalText = element.textContent; | |
| element.textContent = 'Copied!'; | |
| element.classList.add('text-green-400'); | |
| setTimeout(() => { | |
| element.textContent = originalText; | |
| element.classList.remove('text-green-400'); | |
| }, 1000); | |
| } | |
| // Focus input on page load | |
| document.addEventListener('DOMContentLoaded', () => { | |
| document.getElementById('decimalInput').focus(); | |
| }); | |
| </script> | |
| <p style="border-radius: 8px; text-align: center; font-size: 12px; color: #fff; margin-top: 16px;position: fixed; left: 8px; bottom: 8px; z-index: 10; background: rgba(0, 0, 0, 0.8); padding: 4px 8px;">Made with <img src="https://enzostvs-deepsite.hf.space/logo.svg" alt="DeepSite Logo" style="width: 16px; height: 16px; vertical-align: middle;display:inline-block;margin-right:3px;filter:brightness(0) invert(1);"><a href="https://enzostvs-deepsite.hf.space" style="color: #fff;text-decoration: underline;" target="_blank" >DeepSite</a> - 🧬 <a href="https://enzostvs-deepsite.hf.space?remix=adrianoL/conversor-de-n-meros" style="color: #fff;text-decoration: underline;" target="_blank" >Remix</a></p></body> | |
| </html> |