0

I am trying to place a login form in a Bootstrap 3 navbar. I am trying to make the username and password input boxes into input groups. I know a similar question has been asked and answered here before, but none of the solutions work because I need two input groups in a single form.

This is what I have so far:

<div class="navbar navbar-default navbar-static-top" role="navigation">
    <div class="container-fluid">
        <div class="navbar-header">
            <button class="navbar-toggle" data-target="#navbar-collapse" data-toggle="collapse" type="button">
                <span class="sr-only">Toggle Navigation</span>
                <span class="icon-bar"></span>
                <span class="icon-bar"></span>
                <span class="icon-bar"></span>
            </button><a class="navbar-brand" href="/">My Site</a>
        </div>
        <div class="collapse navbar-collapse" id="navbar-collapse">
            <form action="/login" class="navbar-form navbar-right" method="post" role="form">
                <div class="form-group">
                    <div class="input-group">
                        <span class="input-group-addon">
                          <i class="glyphicon glyphicon-user"></i>
                        </span>
                        <input class="form-control" name="andrew_id" placeholder="Andrew ID" type="text" />
                    </div>
                </div>
                <div class="form-group">
                    <div class="input-group">
                        <span class="input-group-addon">
                          <i class="glyphicon glyphicon-lock"></i>
                        </span>
                        <input class="form-control" name="secret" placeholder="Secret Words" type="password" />
                    </div>
                </div>
                <button class="btn btn-primary" type="submit">Log In</button>
            </form>
        </div>
    </div>
</div>

Also in a JSFiddle: http://jsfiddle.net/x6hk4/

Pretty much the two inputs and the button should be right aligned and be inline with the rest of the navbar.

lezed1
  • 316
  • 2
  • 10

1 Answers1

1

This needs some work still, but perhaps it will put you in the right direction:

http://jsfiddle.net/technotarek/5rGFX/

<div class="container">
<nav class="navbar navbar-inverse navbar-default">
    <div class="col-sm-3">
        <a class="navbar-brand">Brand</a>
    </div>
    <form class="navbar-form">
        <div class="col-sm-3 col-sm-offset-2">
            <div class="input-group">
                <span class="input-group-addon">@</span>
                <input type="text" class="form-control">
            </div>
        </div>
        <div class="col-sm-3">
            <div class="input-group">
                <span class="input-group-addon">@</span>
                <input type="text" class="form-control">
            </div>
        </div>
        <div class="col-sm-1">
            <button class="btn btn-primary btn-block" type="button">GO</button>
        </div>
    </form>
</nav>
</div>

It's loosely based off of my responses to Two rows in a navbar with a column spanning two rows

Community
  • 1
  • 1
technoTarek
  • 3,218
  • 2
  • 21
  • 25