In this example you will learn, how to create a responsive inline form with CSS Following is the code to create a responsive inline form with CSS:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 | <!DOCTYPE html> <html> <head> <meta name="viewport" content="width=device-width, initial-scale=1" /> <style> body { font-family: Arial, Helvetica, sans-serif; } * { box-sizing: border-box; } form { display: flex; flex-flow: row wrap; align-items: center; } form label { margin: 5px 10px 5px 0; } form input { margin: 5px 10px 5px 0; padding: 10px; } form button { padding: 10px 20px; font-size: 20px; background-color: rgb(39, 22, 141); border: 1px solid #ddd; color: white; cursor: pointer; font-weight: bolder; border-radius: 4px; } form button:hover { background-color: rgb(113, 65, 225); } @media (max-width: 800px) { form input { margin: 10px 0; } form { flex-direction: column; align-items: stretch; } } </style> </head> <body> <h1>Responsive Inline Form Example</h1> <form> <label for="email">Email:</label> <input type="email" id="email" placeholder="Enter email" name="email" /> <label for="pass">Password:</label> <input type="password" id="pass" placeholder="Enter password" name="pass"/> <button type="submit">Submit</button> </form> </body> </html> |
If you like this question & answer and want to contribute, then write your question & answer and email to freewebmentor[@]gmail.com. Your question and answer will appear on FreeWebMentor.com and help other developers.