Floating Label Input - 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>Floating Label Input</title> <style> body { display: flex; justify-content: center; align-items: center; height: 100vh; background: #ffebee; font-family: 'Poppins', sans-serif; margin: 0; } .input-container { position: relative; width: 300px; } .input-container input { width: 100%; padding: 15px 20px 15px 20px; border: 2px solid #d32f2f; border-radius: 30px; outline: none; background: #fff; font-size: 16px; transition: all 0.3s ease; } .input-container label { position: absolute; left: 20px; top: 50%; transform: translateY(-50%); font-size: 16px; color: #d32f2f; pointer-events: none; transition: all 0.3s ease; } .input-container input:focus + label, .input-container input:valid + label { top: -10px; font-size: 12px; color: #c2185b; } </style> </head> <body> <div class="input-container"> <input type="text" required title="Enter Text" /> <label>Enter your text...</label> </div> </body> </html>