Elegant 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>Elegant Select Box</title> <style> body { font-family: 'Times New Roman', Times, serif; display: flex; justify-content: center; align-items: center; height: 100vh; background: linear-gradient(135deg, #d3cce3, #e9e4f0); } .elegant-select-wrapper { position: relative; display: inline-block; width: 300px; } .elegant-select { position: relative; background-color: #fff; border: 2px solid #555; border-radius: 50px; padding: 15px 30px; cursor: pointer; box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1); transition: all 0.3s ease; } .elegant-select:hover { transform: scale(1.05); box-shadow: 0 8px 16px rgba(0, 0, 0, 0.2); } .elegant-select span { font-size: 22px; } .elegant-select i { font-size: 24px; transition: transform 0.3s ease; } .elegant-select.open i { transform: rotate(180deg); } .elegant-options { position: absolute; top: 100%; left: 0; width: 100%; background-color: #fff; border-radius: 50px; 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; } .elegant-select.open + .elegant-options { max-height: 300px; opacity: 1; visibility: visible; } .elegant-options div { padding: 15px 30px; cursor: pointer; transition: background-color 0.3s ease; display: flex; align-items: center; gap: 10px; } .elegant-options div:hover { background-color: #d3cce3; } .elegant-options div span { font-size: 22px; } .elegant-options div i { font-size: 24px; } .zoom-in { animation: zoomIn 0.5s ease; } @keyframes zoomIn { from { opacity: 0; transform: scale(0.8); } to { opacity: 1; transform: scale(1); } } </style> </head> <body> <div class="elegant-select-wrapper"> <div class="elegant-select"> <span>Select an option</span> <!-- <i>⬇️</i> --> </div> <div class="elegant-options"> <div class="zoom-in" data-value="1"> <i>🌹</i><span>Option 1</span> </div> <div class="zoom-in" data-value="2"> <i>🌺</i><span>Option 2</span> </div> <div class="zoom-in" data-value="3"> <i>🌸</i><span>Option 3</span> </div> </div> </div> <script> const elegantSelect = document.querySelector('.elegant-select'); const elegantOptions = document.querySelector('.elegant-options'); const optionsElegant = document.querySelectorAll('.elegant-options div'); const selectedElegant = document.querySelector('.elegant-select span'); elegantSelect.addEventListener('click', () => { elegantSelect.classList.toggle('open'); elegantOptions.classList.toggle('open'); }); optionsElegant.forEach(option => { option.addEventListener('click', () => { selectedElegant.innerHTML = option.innerHTML; elegantSelect.classList.remove('open'); elegantOptions.classList.remove('open'); }); }); document.addEventListener('click', (e) => { if (!elegantSelect.contains(e.target)) { elegantSelect.classList.remove('open'); elegantOptions.classList.remove('open'); } }); </script> </body> </html>