Sunny Day 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>Sunny Day Select Box</title> <link href="https://fonts.googleapis.com/css2?family=Quicksand:wght@400;700&display=swap" rel="stylesheet"> <style> body { font-family: 'Quicksand', sans-serif; background: linear-gradient(to right, #fceabb, #f8b500); 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: 30px; border: 2px solid #f8b500; padding: 10px 20px; font-size: 16px; color: #f8b500; 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: 30px; border: 2px solid #f8b500; 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: #f8b500; cursor: pointer; transition: all 0.3s ease; } .select-box .select-options li:hover { background-color: #fef2da; border-radius: 30px; } .select-box .select-options li.selected { background-color: #fde4b2; } .emoji { margin-right: 8px; } </style> </head> <body> <div class="select-box"> <div class="custom-select">Pick a time</div> <ul class="select-options"> <li data-value="1">Morning <span class="emoji">🌅</span></li> <li data-value="2">Afternoon <span class="emoji">🏖️</span></li> <li data-value="3">Evening <span class="emoji">🌇</span></li> </ul> <select> <option value="1">Morning</option> <option value="2">Afternoon</option> <option value="3">Evening</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>