Show Output
<!DOCTYPE html> <html lang="en"> <head> <meta charset="utf-8"> <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no"> <title>Bootstrap Navbar with Login Form in Dropdown</title> <link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Varela+Round"> <link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.5.0/css/bootstrap.min.css"> <link rel="stylesheet" href="https://fonts.googleapis.com/icon?family=Material+Icons"> <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css"> <script src="https://code.jquery.com/jquery-3.5.1.min.js"></script> <script src="https://cdn.jsdelivr.net/npm/popper.js@1.16.0/dist/umd/popper.min.js"></script> <script src="https://stackpath.bootstrapcdn.com/bootstrap/4.5.0/js/bootstrap.min.js"></script> <style> body { font-family: 'Varela Round', sans-serif; } .form-control { box-shadow: none; border-radius: 4px; } .navbar { background: #fff; padding-left: 16px; padding-right: 16px; border-bottom: 1px solid #dfe3e8; border-radius: 0; } .nav-link img { border-radius: 50%; width: 36px; height: 36px; margin: -8px 0; float: left; margin-right: 10px; } .navbar .navbar-brand { padding-left: 0; font-size: 20px; padding-right: 50px; } .navbar .navbar-brand b { color: #5c6ac4; } .navbar .form-inline { display: inline-block; } .navbar .navbar-nav { position: relative; } .navbar a, .navbar a:active { color: #888; font-size: 15px; background: transparent; } .search-box { position: relative; } .search-box input { padding-right: 35px; border-color: #dfe3e8; border-radius: 4px !important; box-shadow: none } .search-box .input-group-text { min-width: 35px; border: none; background: transparent; position: absolute; right: 0; z-index: 9; padding: 7px; height: 100%; } .search-box i { color: #a0a5b1; font-size: 19px; } .navbar .btn-primary, .navbar .btn-primary:active { color: #fff; background: #5c6ac4 !important; padding-top: 8px; padding-bottom: 6px; border-radius: 4px; vertical-align: middle; border: none; min-width: 120px; margin: 2px 0; } .navbar .btn-primary:hover, .navbar .btn-primary:focus { color: #fff; background: #5765c1 !important; } .navbar .action-buttons .dropdown-toggle::after { display: none; } .search-box .btn span { transform: scale(0.9); display: inline-block; } .navbar .nav-item i { font-size: 18px; } .navbar .dropdown-item i { font-size: 16px; min-width: 22px; } .navbar .dropdown-menu { border-radius: 1px; border-color: #e5e5e5; box-shadow: 0 2px 8px rgba(0,0,0,.05); } .navbar .navbar-nav .dropdown-menu a { padding: 8px 20px; line-height: normal; } .navbar .navbar-form { border: none; } .navbar .navbar-form-wrapper { padding: 0 15px; } .navbar .login-form label { color: #888; font-weight: normal; } .navbar .dropdown-menu.login-form { width: 280px; padding: 20px; left: auto; right: 0; font-size: 14px; } .navbar .navbar-nav .dropdown-menu.login-form a { padding: 0 !important; color: #5c6ac4; font-weight: normal; } .navbar .navbar-nav .dropdown-menu.login-form a:hover{ text-decoration: underline; } .navbar .dropdown-menu.login-form .checkbox-inline { margin-top: 10px; } @media (min-width: 1200px){ .form-inline .input-group { width: 300px; margin-left: 30px; } } @media (max-width: 768px){ .navbar .dropdown-menu.login-form { width: 100%; padding: 10px 15px; background: transparent; border: none; } .navbar .form-inline { display: block; } .navbar .input-group { width: 100%; } .navbar .navbar-nav .btn-primary, .navbar .navbar-nav .btn-primary:active { display: block; } } </style> <script> // Prevent dropdown menu from closing when click inside the form $(document).on("click", ".navbar-right .dropdown-menu", function(e){ e.stopPropagation(); }); </script> </head> <body> <nav class="navbar navbar-expand-lg navbar-light bg-light"> <a href="#" class="navbar-brand">Brand<b>Name</b></a> <button type="button" class="navbar-toggler" data-toggle="collapse" data-target="#navbarCollapse"> <span class="navbar-toggler-icon"></span> </button> <!-- Collection of nav links, forms, and other content for toggling --> <div id="navbarCollapse" class="collapse navbar-collapse justify-content-start"> <div class="navbar-nav"> <a href="#" class="nav-item nav-link">Home</a> <a href="#" class="nav-item nav-link">About</a> <div class="nav-item dropdown"> <a href="#" data-toggle="dropdown" class="nav-item nav-link dropdown-toggle">Services</a> <div class="dropdown-menu"> <a href="#" class="dropdown-item">Web Design</a> <a href="#" class="dropdown-item">Web Development</a> <a href="#" class="dropdown-item">Graphic Design</a> <a href="#" class="dropdown-item">Digital Marketing</a> </div> </div> <a href="#" class="nav-item nav-link active">Pricing</a> <a href="#" class="nav-item nav-link">Blog</a> <a href="#" class="nav-item nav-link">Contact</a> </div> <form class="navbar-form form-inline"> <div class="input-group search-box"> <input type="text" id="search" class="form-control" placeholder="Search here..."> <div class="input-group-append"> <span class="input-group-text"><i class="material-icons"></i></span> </div> </div> </form> <div class="navbar-nav action-buttons ml-auto"> <a href="#" data-toggle="dropdown" class="nav-item nav-link dropdown-toggle mr-3">Login</a> <div class="dropdown-menu login-form"> <form action="/examples/actions/confirmation.php" method="post"> <div class="form-group"> <label>Username</label> <input type="text" class="form-control" required="required"> </div> <div class="form-group"> <div class="clearfix"> <label>Password</label> <a href="#" class="float-right text-muted"><small>Forgot?</small></a> </div> <input type="password" class="form-control" required="required"> </div> <input type="submit" class="btn btn-primary btn-block" value="Login"> </form> </div> <a href="#" class="btn btn-primary">Get Started</a> </div> </div> </nav> </body> </html>