Fancy Select Box - MeggiTools
Run
Toggle Theme
Share Link
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <title>Fancy Select Box</title> <style> body { font-family: 'Courier New', Courier, monospace; display: flex; justify-content: center; align-items: center; height: 100vh; background: linear-gradient(135deg, #f8ff00, #3ad59f); } .fancy-select-wrapper { position: relative; display: inline-block; width: 300px; } .fancy-select { position: relative; background-color: #fff; border: 2px solid #000; border-radius: 25px; padding: 15px 25px; cursor: pointer; box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1); transition: all 0.3s ease; } .fancy-select:hover { transform: scale(1.05); box-shadow: 0 8px 16px rgba(0, 0, 0, 0.2); } .fancy-select span { font-size: 20px; } .fancy-select i { font-size: 24px; transition: transform 0.3s ease; } .fancy-select.open i { transform: rotate(180deg); } .fancy-options { position: absolute; top: 100%; left: 0; width: 100%; background-color: #fff; border-radius: 25px; box-shadow: 0 8px 16px rgba(0, 0, 0, 0.2); overflow: hidden; max-height: 0; opacity: 0; visibility: hidden; transition: all 0.3s ease; z-index: 10; } .fancy-select.open + .fancy-options { max-height: 300px; opacity: 1; visibility: visible; } .fancy-options div { padding: 15px 25px; cursor: pointer; transition: background-color 0.3s ease; display: flex; align-items: center; gap: 10px; } .fancy-options div:hover { background-color: #f8ff00; } .fancy-options div span { font-size: 20px; } .fancy-options div i { font-size: 24px; } .slide-in { animation: slideIn 0.5s ease; } @keyframes slideIn { from { opacity: 0; transform: translateX(-20px); } to { opacity: 1; transform: translateX(0); } } </style> </head> <body> <div class="fancy-select-wrapper"> <div class="fancy-select"> <span>Select an option</span> <!-- <i>⬇️</i> --> </div> <div class="fancy-options"> <div class="slide-in" data-value="1"> <i>🍇</i><span>Option 1</span> </div> <div class="slide-in" data-value="2"> <i>🍉</i><span>Option 2</span> </div> <div class="slide-in" data-value="3"> <i>🍍</i><span>Option 3</span> </div> </div> </div> <script> const fancySelect = document.querySelector('.fancy-select'); const fancyOptions = document.querySelector('.fancy-options'); const optionsFancy = document.querySelectorAll('.fancy-options div'); const selectedFancy = document.querySelector('.fancy-select span'); fancySelect.addEventListener('click', () => { fancySelect.classList.toggle('open'); fancyOptions.classList.toggle('open'); }); optionsFancy.forEach(option => { option.addEventListener('click', () => { selectedFancy.innerHTML = option.innerHTML; fancySelect.classList.remove('open'); fancyOptions.classList.remove('open'); }); }); document.addEventListener('click', (e) => { if (!fancySelect.contains(e.target)) { fancySelect.classList.remove('open'); fancyOptions.classList.remove('open'); } }); </script> </body> </html>