Modern Search Bar - 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>Modern Search Bar</title> <style> /* CSS Styles */ body { font-family: Arial, sans-serif; background-color: #f0f0f0; display: flex; justify-content: center; align-items: center; height: 100vh; margin: 0; } .search-container { position: relative; width: 400px; max-width: 90%; background-color: #fff; border-radius: 50px; box-shadow: 0 8px 16px rgba(0, 0, 0, 0.1); overflow: hidden; display: flex; align-items: center; } .search-input { width: calc(100% - 60px); padding: 15px 20px; border: none; outline: none; font-size: 16px; border-top-left-radius: 50px; border-bottom-left-radius: 50px; } .search-button { background-color: #4CAF50; color: white; border: none; padding: 15px 20px; cursor: pointer; font-size: 16px; transition: background-color 0.3s ease; border-top-right-radius: 50px; border-bottom-right-radius: 50px; } .search-button:hover { background-color: #45a049; } .search-icon { position: absolute; left: 20px; color: #aaa; } .emoji { font-size: 20px; margin-right: 10px; vertical-align: middle; } </style> <script> /* JS Code */ document.addEventListener('DOMContentLoaded', function() { const searchForm = document.getElementById('search-form'); const searchInput = document.getElementById('search-input'); searchForm.addEventListener('submit', function(event) { event.preventDefault(); const searchQuery = searchInput.value.trim(); if (searchQuery !== '') { alert(`Searching for: ${searchQuery}`); } }); }); </script> </head> <body> <div class="search-container"> <span class="search-icon"><i class="fas fa-search"></i></span> <input id="search-input" type="text" class="search-input" placeholder="Search..."> <button id="search-button" type="submit" class="search-button">Search <i class="fas fa-arrow-right"></i></button> </div> <!-- Font Awesome CDN for icons --> <script src="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.15.4/js/all.min.js" integrity="sha512-h5ZC4a0k1QzEgcwzj5ejHb6JYlVD9a0G47nTnASe5MKu3E4S5SzfA5AZ/i6X5DL5VL/qjAtW/Q2dPprcQfl2CQ==" crossorigin="anonymous" referrerpolicy="no-referrer"></script> </body> </html>