Toggle navigation
☰
Home
HTML
CSS
Scripting
Database
<!DOCTYPE html> <title>My Example</title> <style> .icon-form-container { max-width: 400px; margin: 40px auto; padding: 30px; background-color: #f9fafb; border-radius: 8px; box-shadow: 0 4px 15px rgba(0,0,0,0.1); font-family: sans-serif; } .icon-form-container h2 { text-align: center; margin-bottom: 25px; } .input-group { position: relative; /* This is for positioning the icon */ margin-bottom: 20px; } .input-icon { position: absolute; top: 50%; left: 15px; transform: translateY(-50%); color: #888; pointer-events: none; /* Icon doesn't intercept clicks */ } .input-icon svg { width: 20px; height: 20px; } .form-control-icon { width: 100%; padding: 12px; /* Add padding on the left to make space for the icon */ padding-left: 50px; border: 1px solid #ccc; border-radius: 6px; font-size: 1rem; box-sizing: border-box; transition: border-color 0.2s; } .form-control-icon:focus { outline: none; border-color: #3498db; } .form-control-icon:focus ~ .input-icon { color: #3498db; /* Change icon color on focus */ } .submit-btn { width: 100%; padding: 12px; background-color: #3498db; border: none; border-radius: 6px; color: white; font-size: 1.1rem; font-weight: bold; cursor: pointer; } </style> <div class="icon-form-container"> <h2>Account Login</h2> <form action="#" method="post"> <div class="input-group"> <span class="input-icon"> <!-- User Icon --> <svg viewBox="0 0 24 24" fill="currentColor"><path d="M12 12c2.21 0 4-1.79 4-4s-1.79-4-4-4-4 1.79-4 4 1.79 4 4 4zm0 2c-2.67 0-8 1.34-8 4v2h16v-2c0-2.66-5.33-4-8-4z"></path></svg> </span> <input class="form-control-icon" type="text" placeholder="Username" required> </div> <div class="input-group"> <span class="input-icon"> <!-- Lock Icon --> <svg viewBox="0 0 24 24" fill="currentColor"><path d="M18 8h-1V6c0-2.76-2.24-5-5-5S7 3.24 7 6v2H6c-1.1 0-2 .9-2 2v10c0 1.1.9 2 2 2h12c1.1 0 2-.9 2-2V10c0-1.1-.9-2-2-2zm-6 9c-1.1 0-2-.9-2-2s.9-2 2-2 2 .9 2 2-.9 2-2 2zm3.1-9H8.9V6c0-1.71 1.39-3.1 3.1-3.1 1.71 0 3.1 1.39 3.1 3.1v2z"></path></svg> </span> <input class="form-control-icon" type="password" placeholder="Password" required> </div> <button class="submit-btn" type="submit">Sign In</button> </form> </div>