Pastel Dreams 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>Pastel Dreams Select Box</title> <link href="https://fonts.googleapis.com/css2?family=Poppins:wght@400;600&display=swap" rel="stylesheet"> <style> body { font-family: 'Poppins', sans-serif; background: linear-gradient(to right, #ff9a9e, #fecfef); display: flex; justify-content: center; align-items: center; height: 100vh; margin: 0; } .select-box { position: relative; width: 300px; margin: 50px; } .select-box select { display: none; /* Hide default select */ } .select-box .custom-select { background-color: #ffffff; border-radius: 25px; border: 2px solid #ff9a9e; padding: 10px 20px; font-size: 16px; color: #ff9a9e; cursor: pointer; position: relative; display: flex; justify-content: space-between; align-items: center; box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1); transition: all 0.3s ease; } .select-box .custom-select:hover { box-shadow: 0 6px 8px rgba(0, 0, 0, 0.15); } .select-box .custom-select::after { content: '🌸'; font-size: 18px; margin-left: 10px; } .select-box .select-options { position: absolute; top: 100%; left: 0; right: 0; margin-left: 0; padding-left: 0; background-color: #ffffff; border-radius: 25px; border: 2px solid #ff9a9e; margin-top: 5px; box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1); z-index: 10; opacity: 0; visibility: hidden; transform: translateY(-20px); transition: all 0.3s ease; } .select-box.active .select-options { opacity: 1; visibility: visible; transform: translateY(0); } .select-box .select-options li { list-style: none; padding: 10px 20px; font-size: 16px; color: #ff9a9e; cursor: pointer; transition: all 0.3s ease; } .select-box .select-options li:hover { background-color: #ffeef1; border-radius: 25px; } .select-box .select-options li.selected { background-color: #ffdde5; } .emoji { margin-right: 8px; } </style> </head> <body> <div class="select-box"> <div class="custom-select">Pick a flower</div> <ul class="select-options"> <li data-value="1">Rose <span class="emoji">🌹</span></li> <li data-value="2">Tulip <span class="emoji">🌷</span></li> <li data-value="3">Sunflower <span class="emoji">🌻</span></li> </ul> <select> <option value="1">Rose</option> <option value="2">Tulip</option> <option value="3">Sunflower</option> </select> </div> <script> document.addEventListener('DOMContentLoaded', function() { const selectBox = document.querySelector('.select-box'); const customSelect = selectBox.querySelector('.custom-select'); const selectOptions = selectBox.querySelector('.select-options'); const options = selectOptions.querySelectorAll('li'); const select = selectBox.querySelector('select'); customSelect.addEventListener('click', function() { selectBox.classList.toggle('active'); }); options.forEach(option => { option.addEventListener('click', function() { const value = option.getAttribute('data-value'); const text = option.textContent; customSelect.innerHTML = text + ' <span class="emoji">' + option.querySelector('.emoji').textContent + '</span>'; selectBox.classList.remove('active'); options.forEach(opt => opt.classList.remove('selected')); option.classList.add('selected'); select.value = value; }); }); document.addEventListener('click', function(e) { if (!selectBox.contains(e.target)) { selectBox.classList.remove('active'); } }); }); </script> </body> </html>