I'm trying to align three items in the same row but am having problems doing this in Bootstrap 3. Here is how they look now:
But I want them to be aligned in the same row (horizontally) and not be aligned vertically.
I have a fiddle here: http://jsfiddle.net/DTcHh/2132/
The relevant code is:
<div class="pull-right">
<form action="#" method="post" class="form-horizontal">
<div class="control-label">
<div class="control">
Pull right on a form will only work if the form has a specific width. In most cases you don't want to use that, but use the grid system.
You should use .input-group to add buttons to an input and show them on the same line.
You're not using labels, so there is no use for .form-horizontal.
See the fiddle
<div class="row">
<div class="col-sm-3 col-md-3">
<ul class="nav nav-pills">
<li class="active">Pill1
</li>
<li class=""><span id="pendingcount">Pill2</span>
</li>
</ul>
</div>
<div class="col-sm-6 col-sm-push-3">
<form action="#" method="post">
<input type="hidden" value="Date" name="filtertype" class="dropdown-field">
<div class="input-group">
<span class="input-group-btn">
<button type="button" class="btn btn-default dropdown-toggle" data-toggle="dropdown">Date <span class="caret"></span></button>
<ul class="dropdown-menu">
<li> Date</li>
<li> Requestor</li>
<li> Classification</li>
<li> Destination</li>
<li> Description</li>
<li> File Name</li>
<li> Extracted Text</li>
<li> Extracted Keywords</li>
<li> Status</li>
<li> Scan Code</li>
</ul>
</span>
<input type="text" name="filterterm" value="" class="form-control">
<span class="input-group-btn">
<button type="submit" class="btn btn-default "> <i class="glyphicon glyphicon-search"></i></button>
</span>
</div>
</form>
</div>
</div>
Related
I am using Bootstrap 3 in my web application , and below html produces the layout depicated in the image
<nav class="navbar navbar-inverse">
<div class="container-fluid">
<div class="navbar-header">
<a class="navbar-brand" [routerLink]="['']" routerLinkActive="active" >Books & NoteBooks</a>
</div>
<ul class="nav navbar-nav">
<li ><a [routerLink]="['']">Home</a></li>
<li *ngFor="let category of categories">
<a [routerLink]="['./acategories' ,category.name , 'products']" routerLinkActive="active">{{category.name}}</a>
</li>
<li><a [routerLink]="['./acart']" routerLinkActive="active">
<span *ngIf="cartCount > 0" class="badge">{{cartCount}}</span>
<span class="glyphicon glyphicon-shopping-cart"> Bag</span></a></li>
<li><a [routerLink]="['./aorders']" routerLinkActive="active">Order Details</a></li>
<li><a [routerLink]="['./about']" routerLinkActive="active">About</a></li>
<li> > > > </li>
</ul>
<form class="form-inline" (ngSubmit)="onSearch()">
<div class="form-group">
<label class="sr-only" for="exampleInputAmount">Amount (in dollars)</label>
<div class="input-group">
<input type="text" class="form-control" id="exampleInputAmount" placeholder="Item Name">
</div>
</div>
<input type="submit" class="btn btn-primary" value="Search"/>
</form><br>
</div>
Now I would like to have text box and search button vertical aligned middle , any idea what needs to be modified.
You can try with padding-top and padding-bottom. Check out working solution here jsbin
Hope this will help you.
You can try using the .navbar-form class along with the .form-inline class as:
<form class="form-inline navbar-form" role="form" (ngSubmit)="onSearch()">
<div class="form-group">...
After this, maybe you can get rid of the <br> tag after the form closing tag.
Also, if you want to align the Search box and button to the right corner, you can use .navbar-right as well:
<form class="form-inline navbar-form navbar-right" role="form" (ngSubmit)="onSearch()">
<div class="form-group">...
Supposedly a rather simple question, but I would appreciate some tips all the same.
I have the following Bootstrap html:
<div class="col-xs-6 col-md-3">
<div class="form-group">
<input autocomplete="off" autofocus="" class="form-control" name="Quantity" placeholder="Quantity required" type="text" id="quantity">
</div>
<div class="dropdown">
<button class="btn btn-primary dropdown-toggle" id="touch" type="button" data-toggle="dropdown">grams
<span class="caret"></span></button>
<ul class="dropdown-menu" id="menu">
<li>milligrams</li>
<li>grams</li>
<li>kilograms</li>
</ul>
</div>
</div>
However, currently as shown here: http://www.bootply.com/xlkInfMjJo
the button always seems to sit below the input field. Is there a way to get around this and ensure the button stays in-line with the form field within the same column?
Kind Regards,
Yes, this can be achieved by having additional columns for the button and input field, which needs to be wrapped in a .row
So, you only need to change from:
<div class="col-xs-6 col-md-3">
<div class="form-group">
<input autocomplete="off" autofocus="" class="form-control" name="Quantity" placeholder="Quantity required" type="text" id="quantity">
</div>
<div class="dropdown">
<button class="btn btn-primary dropdown-toggle" id="touch" type="button" data-toggle="dropdown">grams
<span class="caret"></span></button>
<ul class="dropdown-menu" id="menu">
<li>milligrams</li>
<li>grams</li>
<li>kilograms</li>
</ul>
</div>
</div>
To:
<div class="col-xs-6 col-md-3">
<div class="row">
<div class="form-group col-xs-8">
<input autocomplete="off" autofocus="" class="form-control" name="Quantity" placeholder="Quantity required" type="text" id="quantity">
</div>
<div class="dropdown col-xs-4">
<button class="btn btn-primary dropdown-toggle" id="touch" type="button" data-toggle="dropdown">grams
<span class="caret"></span></button>
<ul class="dropdown-menu" id="menu">
<li>milligrams</li>
<li>grams</li>
<li>kilograms</li>
</ul>
</div>
</div>
</div>
This way, the input field will always take 8 units of the width, whereas the button will take 4 - using the default Bootstrap grid system (12 total units).
Would you want to change this ratio, change the .col-xs-* classes newly inserted to your preferred values.
You can also view these changes in this Bootply snippet: http://www.bootply.com/ufUHQgp9bj
I want to embed a simple input search box. I tried to use code like in bootstrap, but I can't make it to work. I have no clue how to do it.
I have this bootstrap code:
<div class="col-sm-3 col-md-3 pull-right">
<form class="navbar-form" role="search">
<div class="input-group">
<input type="text" class="form-control" placeholder="Search"
name="srch-term" id="srch-term">
<div class="input-group-btn">
<button class="btn btn-default" type="submit">
<i class="glyphicon glyphicon-search"></i>
</button>
</div>
</div>
</form>
</div>
Reference: How to add a search box
I have found that : https://ampersandacademy.com/tutorials/materialize-css/navbar-with-autocomplete-search-box
You have to add a div element in the li element of your navbar ul list.
<nav class="white">
<div class="nav-wrapper">
Logo
<ul class="hide-on-med-and-down right">
<li>
<div class="center row">
<div class="col s12 " >
<div class="row" id="topbarsearch">
<div class="input-field col s6 s12 red-text">
<i class="red-text material-icons prefix">search</i>
<input type="text" placeholder="search" id="autocomplete-input" class="autocomplete red-text" >
</div>
</div>
</div>
</div>
</li>
<li>Sass</li>
<li>Components</li>
<li>JavaScript</li>
</ul>
</div>
</nav>
Or this way:
<nav class="blue">
<div class="nav-wrapper">
<i class="material-icons">cloud</i>Logon
<ul id="nav-mobile" class="right hide-on-med-and-down">
<li>
<form>
<div class="input-field">
<input id="search" type="search" required>
<label class="label-icon" for="search"><i class="material-icons">search</i></label>
<i class="material-icons">close</i>
</div>
</form>
</li>
<li>Sass</li>
<li>Components</li>
<li>JavaScript</li>
</ul>
</div>
</nav>
In twitter bootstrap 3 i would like to add a buttongroup in the navbar, but it seems to break the navbar since it creates linebreaks:
<li>
<form class="navbar-form form-inline" >
<div class="input-group">
<input id="filter" class="form-control input-sm" type="text" placeholder="Filter" />
<span class="input-group-btn">
<button id="clearfilter" type="button" class="btn btn-sm btn-default">Clear</button>
</span>
</div>
</form>
</li>
how can i avoid the linebreak in the navbar?
Maybe you don't need the to put the form inside a list item:
<!-- Start Of Example -->
<form class="navbar-form form-inline">
<div class="input-group">
<input id="filter" class="form-control input-sm" type="text" placeholder="Filter" />
<span class="input-group-btn">
<button id="clearfilter" type="button" class="btn btn-sm btn-default">Clear</button>
</span>
</div>
</form>
<!-- End Of Example -->
JS Fiddle Example
Update: another method (you could also use navbar-right to align the ul block to the right)
<!-- Start Of Example -->
<ul class="nav navbar-nav">
<li>
<div class="navbar-form form-inline" role="form">
<div class="form-group">
<input id="filter" class="form-control input-sm" type="text" placeholder="Filter" />
</div>
<div class="form-group">
<button id="clearfilter" type="button" class="btn btn-sm btn-default">Clear</button>
</div>
</div>
</li>
<li>
<li>Action</li>
</li>
</ul>
<!-- End Of Example -->
Example 2
I have a dropdown in bootstrap, but I don't know how to center a form I have within it.
Here is my code;
<div class="navbar navbar-fixed-top">
<div class="navbar-inner">
<div class="container">
<a class="btn btn-navbar" data-toggle="collapse" data-target=".nav-collapse">
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</a>
<a class="brand" href="#">Testing, 123</a>
<div class="nav-collapse">
<ul class="nav">
<li class="active"><i class="icon-home icon-white"></i> Home</li>
<li>Link</li>
<li>Link</li>
<li>Link</li>
<li class="dropdown">
Dropdown <b class="caret"></b>
<div class="dropdown-menu">
<form accept-charset="UTF-8" action="/sessions" method="post">
<fieldset class='textbox login'>
<label id='js-username'>
<span>Username</span>
<input autocomplete="on" id="username" name="username" type="text" size="20px"/>
</label>
<label id='password'>
<span>Password</span>
<input id="userpassword" name="userpassword" type="password" />
</label>
</fieldset>
<fieldset class='subchk'>
<input name="commit" type="submit" value="Log In" />
</fieldset>
</form>
</div>
</li>
</ul>
<form class="navbar-search pull-right" action="">
<input type="text" class="search-query span2" placeholder="Search">
</form>
</div><!-- /.nav-collapse -->
</div><!-- /.container -->
</div><!-- /.navbar-inner -->
</div><!-- /.navbar -->
I have adjusted the width of the dropdown in the css to fit my form, I just can't work out how to center the form within the dropdown.
Without seeing your CSS it's hard to say for sure that this will work, but try this:
.dropdown-menu form {
width: *insert form width here in pixels*;
margin: 0 auto;
}
This answer assumes that the li with the class dropdown is bigger horizontally than your form, and you are trying to center the form within it. To center something horizontally using this method it must have a fixed width, and the width must be smaller than the parent element (in this case the li with the class dropdown).
Edited to add: I didn't realize how old this question was until after I answered it..
Just create a class with some padding and add it to your form tag, like so:
CSS
.wrap {
padding:15px;
}
HTML
<form class="wrap" accept-charset="UTF-8" action="/sessions" method="post">...</form>
Demo: http://jsfiddle.net/a52UY/
use center tag it might be help to you
<center> </center>
<div class="dropdown-menu">
<center>
<form accept-charset="UTF-8" action="/sessions" method="post">
.......
</form>
</center>