Stylish Input Text - 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>Stylish Input Text</title> <style> @import url('https://fonts.googleapis.com/css2?family=Poppins:wght@400;600&display=swap'); @import url('https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.15.4/css/all.min.css'); body { display: flex; justify-content: center; align-items: center; height: 100vh; background: #f0f0f0; font-family: 'Poppins', sans-serif; margin: 0; } .input-container { position: relative; width: 300px; } .input-container input { width: 100%; padding: 15px 40px 15px 20px; border: 2px solid #ccc; border-radius: 30px; outline: none; font-size: 16px; transition: all 0.3s ease; } .input-container input:focus { border-color: #6200ea; box-shadow: 0 0 15px rgba(98, 0, 234, 0.2); } .input-container input:focus + .icon, .input-container input:valid + .icon { color: #6200ea; transform: scale(1.2); } .input-container .icon { position: absolute; right: 15px; top: 50%; transform: translateY(-50%); color: #ccc; transition: all 0.3s ease; } .input-container .emoji { position: absolute; left: -50px; top: 50%; transform: translateY(-50%) scale(0); transition: all 0.3s ease; } .input-container input:focus + .icon + .emoji, .input-container input:valid + .icon + .emoji { transform: translateY(-50%) scale(1); } .emoji { font-size: 24px; } /* Animations */ @keyframes shake { 0% { transform: translateX(0); } 25% { transform: translateX(-5px); } 50% { transform: translateX(5px); } 75% { transform: translateX(-5px); } 100% { transform: translateX(0); } } .input-container input:focus + .icon, .input-container input:valid + .icon { animation: shake 0.5s; } </style> </head> <body> <div class="input-container"> <input type="text" required title="Input Text" placeholder="Enter Text" /> <span class="icon"></span> <span class="emoji">😊</span> </div> <script> document.querySelector('input').addEventListener('input', function() { let emoji = document.querySelector('.emoji'); if (this.value.length > 0) { emoji.textContent = '😊'; } else { emoji.textContent = '😟'; } }); </script> </body> </html>