Glassmorphism 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>Glassmorphism Select Box</title> <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.0.0-beta3/css/all.min.css"> <style> body { margin: 0; padding: 0; font-family: 'Arial', sans-serif; display: flex; justify-content: center; align-items: center; height: 100vh; background: linear-gradient(135deg, #e2a6b3, #f6c6ea); overflow: hidden; } .select-box-container { position: relative; width: 300px; background: rgba(255, 255, 255, 0.1); border-radius: 12px; box-shadow: 0 6px 24px rgba(0, 0, 0, 0.3); overflow: hidden; font-size: 1rem; } .select-box { width: 100%; padding: 12px 16px; background: linear-gradient(135deg, #ff9a8b, #ff6a88); border: none; border-radius: 8px; color: #000; appearance: none; outline: none; font-size: 1rem; cursor: pointer; transition: background 0.3s ease; } .select-box::-ms-expand { display: none; } .select-box:focus { background: linear-gradient(135deg, #ff6a88, #ff9a8b); } .select-box-container::before { content: "\f078"; font-family: 'Font Awesome 5 Free'; font-weight: 900; position: absolute; top: 50%; right: 16px; transform: translateY(-50%); color: #000; font-size: 1.2rem; pointer-events: none; transition: color 0.3s ease; } .select-box:focus + .select-box-container::before { color: #000; } .options-container { display: none; position: absolute; width: 100%; background: rgba(255, 255, 255, 0.9); backdrop-filter: blur(10px); border-radius: 8px; box-shadow: 0 6px 24px rgba(0, 0, 0, 0.3); border: 1px solid rgba(255, 255, 255, 0.3); z-index: 1; } .options-container.active { display: block; } .option { padding: 12px 16px; cursor: pointer; transition: background 0.3s ease; } .option:hover { background: #f5f5f5; } </style> </head> <body> <div class="select-box-container" id="selectBoxContainer"> <select class="select-box" id="selectBox"> <option value="" disabled selected>Select an option</option> <option value="1">Option 1</option> <option value="2">Option 2</option> <option value="3">Option 3</option> <option value="4">Option 4</option> </select> <div class="options-container" id="optionsContainer"> <div class="option" data-value="1">Option 1</div> <div class="option" data-value="2">Option 2</div> <div class="option" data-value="3">Option 3</div> <div class="option" data-value="4">Option 4</div> </div> </div> <script> const selectBox = document.getElementById('selectBox'); const selectBoxContainer = document.getElementById('selectBoxContainer'); const optionsContainer = document.getElementById('optionsContainer'); selectBox.addEventListener('focus', () => { optionsContainer.classList.add('active'); }); selectBox.addEventListener('blur', () => { optionsContainer.classList.remove('active'); }); optionsContainer.addEventListener('click', (e) => { if (e.target.classList.contains('option')) { selectBox.value = e.target.getAttribute('data-value'); selectBox.dispatchEvent(new Event('change')); optionsContainer.classList.remove('active'); } }); selectBox.addEventListener('change', () => { const selectedOption = selectBox.querySelector(`option[value="${selectBox.value}"]`); selectBox.style.background = `linear-gradient(135deg, #ff6a88, #ff9a8b)`; selectBox.style.color = '#fff'; }); </script> </body> </html>