Playful 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>Playful Select Box</title> <style> body { font-family: 'Comic Sans MS', cursive, sans-serif; display: flex; justify-content: center; align-items: center; height: 100vh; background: linear-gradient(135deg, #f093fb, #f5576c); } .playful-select-wrapper { position: relative; display: inline-block; width: 200px; } .playful-select { position: relative; background-color: #fff; border: 2px dashed #ff4081; border-radius: 10px; padding: 12px 18px; cursor: pointer; box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1); transition: all 0.3s ease; } .playful-select:hover { transform: scale(1.05); box-shadow: 0 8px 16px rgba(0, 0, 0, 0.2); } .playful-select span { font-size: 18px; } .playful-select i { font-size: 20px; transition: transform 0.3s ease; } .playful-select.open i { transform: rotate(180deg); } .playful-options { position: absolute; top: 100%; left: 0; width: 100%; background-color: #fff; border-radius: 10px; 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; } .playful-select.open + .playful-options { max-height: 250px; opacity: 1; visibility: visible; } .playful-options div { padding: 12px 18px; cursor: pointer; transition: background-color 0.3s ease; display: flex; align-items: center; gap: 10px; } .playful-options div:hover { background-color: #f093fb; } .playful-options div span { font-size: 18px; } .playful-options div i { font-size: 20px; } .bounce-in { animation: bounceIn 0.5s ease; } @keyframes bounceIn { from { opacity: 0; transform: translateY(-20px); } to { opacity: 1; transform: translateY(0); } } </style> </head> <body> <div class="playful-select-wrapper"> <div class="playful-select"> <span>Select an option</span> <!-- <i>⬇️</i> --> </div> <div class="playful-options"> <div class="bounce-in" data-value="1"> <i>🎉</i><span>Option 1</span> </div> <div class="bounce-in" data-value="2"> <i>🎊</i><span>Option 2</span> </div> <div class="bounce-in" data-value="3"> <i>🎁</i><span>Option 3</span> </div> </div> </div> <script> const playfulSelect = document.querySelector('.playful-select'); const playfulOptions = document.querySelector('.playful-options'); const optionsPlayful = document.querySelectorAll('.playful-options div'); const selectedPlayful = document.querySelector('.playful-select span'); playfulSelect.addEventListener('click', () => { playfulSelect.classList.toggle('open'); playfulOptions.classList.toggle('open'); }); optionsPlayful.forEach(option => { option.addEventListener('click', () => { selectedPlayful.innerHTML = option.innerHTML; playfulSelect.classList.remove('open'); playfulOptions.classList.remove('open'); }); }); document.addEventListener('click', (e) => { if (!playfulSelect.contains(e.target)) { playfulSelect.classList.remove('open'); playfulOptions.classList.remove('open'); } }); </script> </body> </html>