inline form in bootstrap3 - html

I'm trying to have 2 input fields next to each other in a (bootstrap-css) col-md, but can't seem to get it right.
Here is what I have so far
https://jsfiddle.net/9hrx59bd/
It also doesn't help when I put both input fields in the same input group, by removing this:
...
</div>
<div class="input-group ">
How can I get them next to each other, and use the full width?

You need to make both input-groups a col-md-6, here is the result: link
<div class="row">
<form class="form-inline" id="searchform" action="" accept-charset="utf-8" method="post">
<div class="input-group col-md-6 col-sm-6 col-xs-6">
<input class=" form-control " placeholder="city" id="location" type="text" name="location">
</div>
<div class="input-group col-md-6 col-sm-6 col-xs-6">
<input class="search-query form-control newtab-search-text" placeholder="keywords or company name" id="kw" type="text" name="job">
<span class="input-group-btn">
<button class="btn btn-danger" type="submit">
<span class=" glyphicon glyphicon-search" ></span>
</button>
</span>
</div>
</form>
</div>
Edit
I made it work on smaller screens by adding col-sm-6 and col-xs-6 aswell

Bootstrap Inline Form
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet" />
<div class="container">
<div class="row">
<form id="searchform" action="" accept-charset="utf-8" method="post">
<div class="col-md-6">
<div class=" form-group">
<input class="form-control" placeholder="city" id="location" type="text" name="location">
</div>
</div>
<div class="col-md-6">
<div class="form-group input-group">
<input class="search-query form-control newtab-search-text" placeholder="keywords or company name" id="kw" type="text" name="job">
<span class="input-group-btn">
<button class="btn btn-danger" type="submit">
<span class=" glyphicon glyphicon-search" ></span>
</button>
</span>
</div>
</div>
</form>
</div>
</div>

I think you just want a form-control and an input-group.
<div class="row">
<div class="col-md-6">
<form class="form-inline" id="searchform" action="" accept-charset="utf-8" method="post">
<input class="form-control" placeholder="city" id="location" type="text" name="location">
<div class="input-group">
<input class="search-query form-control newtab-search-text" placeholder="keywords or company name" id="kw" type="text" name="job">
<span class="input-group-btn">
<button class="btn btn-danger" type="submit"><i class="glyphicon glyphicon-search"></i></button>
</span>
</div>
</form>
</div>
</div>
Demo
EDIT: Another option is to use the grid columns, but remove the padding:
.pr-0{
padding-right:0;
}
.pl-0{
padding-left:0;
}
<form class="row" id="searchform" action="" accept-charset="utf-8" method="post">
<div class="col-xs-6 col-sm-3 pr-0">
<input class="form-control" placeholder="city" id="location" type="text" name="location">
</div>
<div class="col-xs-6 col-sm-3 pl-0">
<div class="input-group">
<input class="search-query form-control newtab-search-text" placeholder="keywords or company name" id="kw" type="text" name="job">
<span class="input-group-btn">
<button class="btn btn-danger" type="submit"><i class="glyphicon glyphicon-search"></i></button>
</span>
</div>
</div>
</form>
See the 2nd item in the demo

Assuming you want the input next to each other, refer code:
Please view the results in full page view.
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet" />
<form action="" class="form-inline">
<div class="form-group">
<input type="text" class="form-control" placeholder="Username">
</div>
<div class="form-group">
<input type="text" class="form-control" placeholder="Password">
</div>
</form>

Related

Bootstrap - Centering textfields

Good day! In my log in form, I want my text fields to put it in to center using bootstrap. I already used class="form-inline justify-content-center" but it isn't working.
Code:
<div class="col-lg-6 col-md-6 col-sm-6 col-xs-6" style="background: #1b4d32;">
<form role="form" method="post" action="<?=base_url()?>login/login_submit" class="form-inline justify-content-center">
<br/><br/><br/><br/><br/><br/>
<p id="sign-lbl" style="text-align: center">Please enter your username and<br/>
password to login.</p><br/><br/>
<div class="form-group">
<div class="col-xs-6">
<input type="text" name="username" id="email" class="form-control" placeholder="Username" style="border-radius: 25px;">
</div>
</div><br/><br/>
<div class="form-group">
<div class="col-xs-6">
<input type="password" name="password" id="password" class="form-control" placeholder="Password" style="border-radius: 25px;">
</div>
</div>
<br/><br/>
<span class="button-checkbox">
<input type="checkbox" name="remember_me" id="remember_me" checked="checked" class="hidden">
<a class="btn" data-color="info">Stay Signed In</a>
Forgot Password?
</span>
<div class="row">
<div class="col-xs-6 col-sm-6 col-md-6">
<input type="submit" class="btn btn-lg btn-success btn-block" value="Sign In">
</div>
</div>
</form>
</div>
</div>
So far this is my output:
https://prnt.sc/h675qg / https://jsfiddle.net/kf2c8trp/
Thank you very much
Simply add this code to your CSS:
form {
text-align:center;
}
or as #Connum said, use text-center of bootstrap classes. Read more here
After adding the bootstrap css file to your fiddle and the class text-center to the form, your inputs are being displayed centered: https://jsfiddle.net/kf2c8trp/4/
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet"/>
<div class="col-lg-6 col-md-6 col-sm-6 col-xs-6" style="background: #1b4d32;">
<form role="form" method="post" action="<?=base_url()?>login/login_submit" class="form-inline justify-content-center text-center">
<br/><br/><br/><br/><br/><br/>
<p id="sign-lbl" style="text-align: center">Please enter your username and<br/>
password to login.</p><br/><br/>
<div class="form-group">
<div class="col-xs-6">
<input type="text" name="username" id="email" class="form-control" placeholder="Username" style="border-radius: 25px;">
</div>
</div><br/><br/>
<div class="form-group">
<div class="col-xs-6">
<input type="password" name="password" id="password" class="form-control" placeholder="Password" style="border-radius: 25px;">
</div>
</div>
<br/><br/>
<span class="button-checkbox">
<input type="checkbox" name="remember_me" id="remember_me" checked="checked" class="hidden">
<a class="btn" data-color="info">Stay Signed In</a>
Forgot Password?
</span>
<div class="row">
<div class="col-xs-6 col-sm-6 col-md-6">
<input type="submit" class="btn btn-lg btn-success btn-block" value="Sign In">
</div>
</div>
</form>
</div>
Firstly, you are doing a lot of things wrong. Trying to create space with <br/> when you should be using margin or padding is not really cool :). Also, Inline styling is highly discouraged and Justify-content-centre work with flexboxes. That being said check-out the working example below, I have changed some of your bootstrap class and add few scss link below:
<div class=" col-xs-12 container" >
<form class="col-xs-12" role="form" method="post" action="<?=base_url()?>login/login_submit" >
<p id="sign-lbl">Please enter your username and<br/>
password to login.</p>
<div class="col-xs-6 col-xs-offset-3 form-group">
<div>
<input type="text" name="username" id="email" class="form-control" placeholder="Username">
</div>
</div><br/><br/>
<div class="col-xs-6 col-xs-offset-3 form-group">
<div>
<input type="password" name="password" id="password" class="form-control" placeholder="Password">
</div>
</div>
<span class="button-checkbox">
<input type="checkbox" name="remember_me" id="remember_me" checked="checked" class="hidden">
<a class="btn" data-color="info">Stay Signed In</a>
Forgot Password?
</span>
<div class="row">
<div class="col-xs-offset-3 col-xs-6 ">
<input type="submit" class="btn btn-lg btn-success btn-block" value="Sign In">
</div>
</div>
</form>
</div>
Check out the updated link

Bootstrap formatting inline in one row

Solved: JSfiddle
here is what I wanted, sample:
<form class="form-horizontal">
<div class="form-group">
<label for="name" class="col-xs-2 control-label">Name</label>
<div class="col-xs-4">
<input type="text" class="form-control col-sm-10" name="name" placeholder="name" />
</div>
</div>
<div class="form-group">
<label for="birthday" class="col-xs-2 control-label">Birthday</label>
<div class="col-xs-10">
<div class="form-inline">
<div class="form-group">
<input type="text" class="form-control" placeholder="year" />
</div>
<div class="form-group">
<input type="text" class="form-control" placeholder="month" />
</div>
<div class="form-group">
<input type="text" class="form-control" placeholder="day" />
</div>
<div class="form-group">
<button class="btn btn-default" type="submit"><i class="glyphicon glyphicon-search"></i></button>
</div>
</div>
</div>
</div>
<div class="form-group">
<label for="name" class="col-xs-2 control-label">Name</label>
<div class="col-xs-4">
<input type="text" class="form-control col-sm-10" name="name" placeholder="name" />
</div>
</div>
</form>
.css:
.form-inline .form-group {
margin-left: 0;
margin-right: 0;
}
END
UPDATE:
I see where my problem is but i have form-horizontal that I want and if i change it to form-inline everything else is messed up please have a look at the updated jsfiddle
How do I make it inline in one row without spacing as shown in the screen shot:
<form class="navbar-form form-horizontal" role="search" style="padding:0" _lpchecked="1">
<div class="form-group col-md-12">
<label class="col-sm-3 control-label">Location</label>
<div class="col-md-3">
<input class="form-control ng-pristine ng-valid" id="src1" placeholder="Search" type="text">
</div>
<div class="col-md-3">
<input class="form-control ng-pristine ng-valid" id="srch2" placeholder="State" type="text">
</div>
<div class="col-md-3">
<input class="form-control ng-pristine ng-valid" id="srch3" placeholder="City" type="text">
</div>
<div class="col-md-2">
<button class="btn btn-default" type="submit"><i class="glyphicon glyphicon-search"></i></button>
</div>
</div>
</form>
as you can see spacing between the input:
JSFiddle
Use form-inline instead of form-horizontal:
<form class="navbar-form form-inline" role="search" style="padding:0" _lpchecked="1">
<div class="form-group">
<label class="control-label">Location</label>
<input class="form-control ng-pristine ng-valid" id="src1" placeholder="Search" type="text">
</div>
<div class="form-group">
<input class="form-control ng-pristine ng-valid" id="srch2" placeholder="State" type="text">
</div>
<div class="form-group">
<input class="form-control ng-pristine ng-valid" id="srch3" placeholder="City" type="text">
</div>
<div class="form-group">
<button class="btn btn-default" type="submit"><i class="glyphicon glyphicon-search"></i></button>
</div>
</div>
bootply
Simple calculation: col-sm-3 * 4 + col-sm-2 == col-sm-14 Which is not good. You should make sure that the total will not exceed 12 cols for each row.
Suggestion - change the first col-sm-3 to col-sm-1

How to add link or button to form-group in bootstrap

How can I add link or button right of input not using class="form-inline".
<form class="form-horizontal" role="form" action="" method="post">
<div class="form-group" id="formGroupSubject">
<label for="inputSubjectx" class="col-sm-2 control-label">Name</label>
<div class="col-sm-10">
<input type="text" class="form-control" id="inputSubjectx" name="inputSubjectx" >
</div>
</div>
<div class="form-group" >
<div class="col-sm-offset-9 col-sm-2" col-sm-offset-1>
<button type="submit" class="btn btn-warning">Send</button>
</div>
</div>
</form>
You can use Bootstrap Input Groups
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/css/bootstrap.min.css" rel="stylesheet" />
<div class="container">
<form class="form-horizontal" role="form" action="" method="post">
<div class="form-group" id="formGroupSubject">
<label for="inputSubjectx" class="col-sm-2 control-label">Name</label>
<div class="col-sm-10">
<div class="input-group">
<input type="text" class="form-control" id="inputSubjectx" name="inputSubjectx" /> <span class="input-group-btn">
<button class="btn btn-danger" type="button">Press!</button>
</span>
</div>
</div>
</div>
<div class="form-group">
<div class="col-sm-offset-9 col-sm-2" col-sm-offset-1>
<button type="submit" class="btn btn-warning">Send</button>
</div>
</div>
</form>
</div>

Bootstrap full width search box

I try to make a full width search box. its working in tab and mobile but not working in desktop or laptop
Here is my code
<div class="row">
<div class="col-md-offset-2 col-sm-offset-2 col-xs-offset-1 col-md-8 col-sm-8 col-xs-10">
<form action="" autocomplete="off" class="navbar-form" method="post" accept-charset="utf-8">
<div class="input-group">
<input name="searchtext" value="" class="form-control" type="text">
<span class="input-group-btn">
<button class="btn btn-default" type="submit" id="addressSearch">
<span class="icon-search"></span>
</button>
</span>
</div>
</form>
</div>
</div>
when I see the responsive view its working on mobile and tab view
But its not working in desktop view
Remove you nav-bar class and add form-horizontal
<form action="" autocomplete="off" class="form-horizontal" method="post" accept-charset="utf-8">
<div class="input-group">
<input name="searchtext" value="" class="form-control" type="text">
<span class="input-group-btn">
<button class="btn btn-default" type="submit" id="addressSearch">
<span class="icon-search"></span>
</button>
</span>
</div>
</form>
Give col-lg-12 class to the div
<form action="" autocomplete="off" class="navbar-form" method="post" accept-charset="utf-8">
<div class="input-group col-lg-12">
<input name="searchtext" style="width:100%" value="" class="form-control" type="text">
<span class="input-group-btn">
<button class="btn btn-default" type="submit" id="addressSearch">
<span class="icon-search"></span>
</button>
</span>
</div>
<div class="row">
<div class="col-md-offset-2 col-sm-offset-2 col-xs-offset-1 col-xs-10 col-sm-8 col-md-8 col-lg-6">
<div class="form-group">
<input name="searchtext" value="" class="form-control" type="text">
<span class="input-group-btn">
<button class="btn btn-default" type="submit" id="addressSearch">
<span class="icon-search"></span>
</button>
</span>
</div>
</div>
</div>

center div inside column bootstrap

I'm trying to center a form inside a column in bootstrap. Is it possible because I'm searching for more than an hour and still found nothing. I'm a novice in bootstrap...
My code:
<div class="container-fluid">
<!--Row with two equal columns-->
<div class="row">
<div class="col-sm-8">
<form class="form-inline row" role="form" action="index.php" method="post">
<input class="form-control" type="text" name="kerkim" id="input_main" value="">
<i id="slash">|</i>
<div class="input-group">
<input id="address" class="form-control" type="text" >
<div class="input-group-btn">
<button type="text" class="btn btn-warning"><i>Me gjej</i></button>
</div>
</div>
<button type="submit" class="btn btn-warning"><i class="glyphicon glyphicon-search"></i></button>
</form>
</div>
<div class="col-sm-2"><h3>Second left</h3></div>
<div class="col-sm-2"><h3>Second right</h3></div>
You can use offset value in form col-md-offset-4
<form class="form-inline row col-md-offset-4" method="post" action="index.php" role="form">
For more detail go with LINK
add a class to form "center_form"
<form class="form-inline row center_form" role="form" action="index.php" method="post">
and add below css
.center_form{margin:0 auto;}
You need to remove class row from your form element, as it contains no columns. Next, you need to use css to center your form.
Try this:
HTML
<div class="container-fluid">
<!--Row with two equal columns-->
<div class="row">
<div class="col-sm-8">
<form class="form-inline centered" role="form" action="index.php" method="post">
<input class="form-control" type="text" name="kerkim" id="input_main" value="">
<i id="slash">|</i>
<div class="input-group">
<input id="address" class="form-control" type="text" >
<div class="input-group-btn">
<button type="text" class="btn btn-warning"><i>Me gjej</i></button>
</div>
</div>
<button type="submit" class="btn btn-warning"><i class="glyphicon glyphicon-search"></i></button>
</form>
</div>
<div class="col-sm-2"><h3>Second left</h3></div>
<div class="col-sm-2"><h3>Second right</h3></div>
</div>
</div>
CSS
.centered {
margin: auto;
}
Alternatively, you can use this html layout to accomplish a centered form:
<div class="container-fluid">
<!--Row with two equal columns-->
<div class="row">
<div class="col-sm-8">
<div class="row">
<form class="form-inline centered col-sm-8 col-sm-offset-2" role="form" action="index.php" method="post">
<input class="form-control" type="text" name="kerkim" id="input_main" value="">
<i id="slash">|</i>
<div class="input-group">
<input id="address" class="form-control" type="text" >
<div class="input-group-btn">
<button type="text" class="btn btn-warning"><i>Me gjej</i></button>
</div>
</div>
<button type="submit" class="btn btn-warning"><i class="glyphicon glyphicon-search"></i></button>
</form>
</div>
<div class="col-sm-2"><h3>Second left</h3></div>
<div class="col-sm-2"><h3>Second right</h3></div>
</div>
</div>
</div>