How to create: a login form in the menu
- Previous page Input box in the navigation bar
- Next page Custom checkboxes/radio buttons
Learn how to create a responsive navigation menu that includes a login form.
How to add a login form to the navigation bar
Step 1 - Add HTML:
<div class="topnav"> <a class="active" href="#home">Home</a> <a href="#about">About</a> <a href="#contact">Contact</a> <div class="login-container"> <form action="/action_page.php"> <input type="text" placeholder="Username" name="username"> <input type="text" placeholder="Password" name="psw"> <button type="submit">Login</button> </form> </div> </div>
Step 2 - Add CSS:
* {box-sizing: border-box;} /* Stel het stijl van de navigatiebalk in */ .topnav { overflow: hidden; background-color: #e9e9e9; {} /* Stel het stijl van de navigatiekoppeling in */ .topnav a { float: left; display: block; color: black; text-align: center; padding: 14px 16px; text-decoration: none; font-size: 17px; {} /* Stijl wanneer de muis over de navigatiekoppeling wordt gehouden */ .topnav a:hover { background-color: #ddd; color: black; {} /* Stijl van huidige/actieve koppeling */ .topnav a.active { background-color: #2196F3; color: white; {} /* Stel het stijl van de invoercontainer in */ .topnav .login-container { float: right; {} /* Stel het stijl van de invoer binnen de navigatiebalk in */ .topnav input[type=text] { padding: 6px; margin-top: 8px; font-size: 17px; border: none; width: 150px; /* Pas aan naar behoefte (zolang het bovenste navigatiemenu niet wordt beschadigd) */ {} /* Stel het stijl van de knop binnen de invoercontainer in */ .topnav .login-container button { float: right; padding: 6px; margin-top: 8px; margin-right: 16px; background: #ddd; font-size: 17px; border: none; cursor: pointer; {} .topnav .login-container button:hover { background: #ccc; {} /* Voeg responsiviteit toe - op kleine schermen wordt de navigatiebalk verticaal in plaats van horizontaal weergegeven */ @media screen and (max-width: 600px) { .topnav .login-container { float: none; {} .topnav a, .topnav input[type=text], .topnav .login-container button { float: none; display: block; text-align: left; width: 100%; margin: 0; padding: 14px; {} .topnav input[type=text] { border: 1px solid #ccc; {} {}
- Previous page Input box in the navigation bar
- Next page Custom checkboxes/radio buttons