Custom Stylish 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>Custom Stylish Select Box</title> <style> body { font-family: 'Arial', sans-serif; display: flex; justify-content: center; align-items: center; height: 100vh; background: linear-gradient(45deg, #ffafbd, #ffc3a0); } .custom-select-wrapper { position: relative; display: inline-block; width: 300px; } .custom-select { position: relative; display: flex; align-items: center; justify-content: space-between; background-color: #fff; border-radius: 8px; padding: 10px 20px; cursor: pointer; box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1); transition: all 0.3s ease; } .custom-select:hover { transform: translateY(-2px); box-shadow: 0 4px 20px rgba(0, 0, 0, 0.2); } .custom-select span { font-size: 18px; } .custom-select i { font-size: 20px; transition: transform 0.3s ease; } .custom-select.open i { transform: rotate(-180deg); } .custom-options { position: absolute; top: 100%; left: 0; width: 100%; background-color: #fff; border-radius: 8px; box-shadow: 0 4px 20px rgba(0, 0, 0, 0.2); overflow: hidden; max-height: 0; opacity: 0; visibility: hidden; transition: all 0.3s ease; z-index: 10; } .custom-select.open + .custom-options { max-height: 300px; opacity: 1; visibility: visible; } .custom-options div { padding: 10px 20px; cursor: pointer; transition: background-color 0.3s ease; display: flex; align-items: center; gap: 10px; } .custom-options div:hover { background-color: #ffafbd; } .custom-options div span { font-size: 18px; } .custom-options div i { font-size: 20px; } .fade-in { animation: fadeIn 0.5s ease; } @keyframes fadeIn { from { opacity: 0; transform: translateY(-10px); } to { opacity: 1; transform: translateY(0); } } </style> </head> <body> <div class="custom-select-wrapper"> <div class="custom-select"> <span>Select an option</span> <!-- <i>⬇️</i> --> </div> <div class="custom-options"> <div class="fade-in" data-value="1"> <i>🍎</i><span>Option 1</span> </div> <div class="fade-in" data-value="2"> <i>🍌</i><span>Option 2</span> </div> <div class="fade-in" data-value="3"> <i>🍒</i><span>Option 3</span> </div> </div> </div> <script> const customSelect = document.querySelector('.custom-select'); const customOptions = document.querySelector('.custom-options'); const options = document.querySelectorAll('.custom-options div'); const selected = document.querySelector('.custom-select span'); customSelect.addEventListener('click', () => { customSelect.classList.toggle('open'); customOptions.classList.toggle('open'); }); options.forEach(option => { option.addEventListener('click', () => { selected.innerHTML = option.innerHTML; customSelect.classList.remove('open'); customOptions.classList.remove('open'); }); }); document.addEventListener('click', (e) => { if (!customSelect.contains(e.target)) { customSelect.classList.remove('open'); customOptions.classList.remove('open'); } }); </script> </body> </html>