Bootstrap class "form-inline" Break inside div - html

I´m trying to stop/break the form-inline class inside just one div.
I have three input fields.
I´d like the two first one left side, ontop of each other.
And the third on the rigth side of them.
check Fiddle
https://jsfiddle.net/rjc5s1vn/
This is a pretty large form, so i don´t like to remove form-inline from the parent form.
HTML
<form class="form-inline well col-md-10">
<!-- Produkt input-->
<div class="input-group col-md-4 form">
<div class="input-group-addon"><i class="glyphicon glyphicon-wrench"></i></div>
<input id="produkt" name="produkt" type="text" placeholder="Produkt" class="form-control input-sm">
<br>
<div class="input-group-addon"><i class="glyphicon glyphicon-transfer"></i></div>
<input id="objekt_lev_dat" name="objekt_lev_dat" type="text" placeholder="Leverans datum" class="form-control input-sm" required>
</div>
<!-- Adress Textarea -->
<div class="input-group col-md-4">
<div class="input-group-addon"><i class="fa fa-truck"></i></div>
<textarea class="form-control" id="objekt_mont_adress" name="objekt_mont_adress" rows="3" placeholder="Adress" required> </textarea>
</div>
</form>

Try the following: https://jsfiddle.net/rjc5s1vn/3/
I wrapped your inputs and glyphicons pairings into two wrapping <div class="test">:
<form class="form-inline well col-md-10">
<!-- Produkt input-->
<div class="input-group col-md-4 form">
<div class="test">
<div class="input-group-addon"><i class="glyphicon glyphicon-wrench"></i></div>
<input id="produkt" name="produkt" type="text" placeholder="Produkt" class="form-control input-sm">
</div>
<br>
<div class="test">
<div class="input-group-addon"><i class="glyphicon glyphicon-transfer"></i></div>
<input id="objekt_lev_dat" name="objekt_lev_dat" type="text" placeholder="Leverans datum" class="form-control input-sm" required>
</div>
</div>
<!-- Adress Textarea -->
<div class="input-group col-md-4">
<div class="input-group-addon"><i class="fa fa-truck"></i></div>
<textarea class="form-control" id="objekt_mont_adress" name="objekt_mont_adress" rows="3" placeholder="Adress" required></textarea>
</div>
</form>
CSS:
.form-inline > .input-group:first-child > .test {
display: block;
}
.form-inline > .input-group:first-child > .test div, .form-inline > .input-group:first-child > .test input {
display: inline-block;
float: left;
}

I solved it like this:<br>
Notice more nestled <div><br>
<!-- Product input-->
<div class="col-md-4" style="padding-left: 0px">
<div class="input-group input-group-sm col-md-12">
<div class="input-group-addon"><i class="glyphicon glyphicon-wrench"></i></div>
<input id="produkt" name="produkt" type="text" placeholder="Produkt" class="form-control">
</div>
<br>
<div class="input-group input-group-sm col-md-12">
<div class="input-group-addon"><i class="glyphicon glyphicon-transfer"></i></div>
<input id="objekt_lev_dat" name="objekt_lev_dat" type="text" placeholder="Leverans datum" class="form-control" required>
</div>
</div>

I have a solution. You can try by this way. I just used core bootstrap and some css. Have a look on my demo
<form class="form-inline well col-md-10">
<div class="item">
<div class="input-group input-group-sm input_item">
<span class="input-group-addon" id="sizing-addon1">#</span>
<input type="text" class="form-control" placeholder="Username" aria-describedby="sizing-addon1">
</div>
<div class="input-group input-group-sm input_item">
<span class="input-group-addon" id="sizing-addon1">#</span>
<textarea class="form-control" placeholder="Username" aria-describedby="sizing-addon1"></textarea>
</div>
<div class="input-group input-group-sm input_item">
<span class="input-group-addon" id="sizing-addon1">#</span>
<input type="text" class="form-control" placeholder="Username" aria-describedby="sizing-addon1">
</div>
<div class="clearfix">
</div>
</div>
</form>
.form-inline .item .input_item{
width:calc(50% - 7.5px);
margin-bottom:15px;
}
.form-inline .item .input_item textarea{
min-height:75px;
}
.form-inline .item .input_item:first-child{
float:left;
}
.form-inline .item .input_item:nth-child(2){
float:right;
}
.form-inline .item .input_item:last-child{
float:left;
}

Try out this
<form class="form-inline">
<div class="input-group col-md-4 form">
<div class="input-group-addon"><i class="glyphicon glyphicon-wrench"></i></div>
<input id="produkt" name="produkt" type="text" placeholder="Produkt" class="form-control input-sm">
<br></div>
<div class="input-group col-md-4 form">
<div class="input-group-addon"><i class="glyphicon glyphicon-transfer"></i></div>
<input id="objekt_lev_dat" name="objekt_lev_dat" type="text" placeholder="Leverans datum" class="form-control input-sm" required>
</div>
<div class="input-group col-md-4">
<div class="input-group-addon"><i class="fa fa-truck"></i></div>
<textarea class="form-control" id="objekt_mont_adress" name="objekt_mont_adress" rows="3" placeholder="Adress" required></textarea>
</div>
</form>
See Demo

Related

Bootstrap inline form with labels above input

I want to create an inline form using bootstrap with labels above input text fields but the result looks so messed up.
This is what i tried:
<form id="form" method="post" class="form-inline" >
<div class="row">
<div class="col-md-2">
<label for="from">from:</label>
<input type="text" class="form-control form-text" />
</div>
<div class="col-md-2">
<label for="to">to:</label>
<input type="text" class="form-control form-text"/>
</div>
<div class="input-group date col-md-2" id="datepicker">
<label for="checkin">check in</label>
<input type="text" class="form-control datepicker" name="processdate" />
<span class="input-group-addon btn"><i class="glyphicon glyphicon-calendar"></i> </span>
</div>
<div class="input-group date col-md-2" id="datepicker">
<label for="checkout">check out</label>
<input type="text" class="form-control datepicker" name="processdate" />
<span class="input-group-addon btn"><i class="glyphicon glyphicon-calendar"></i> </span>
</div>
<div class="col-md-2">
<input type="submit" class="btn btn-default" value="submit"/>
</div>
</div>
</form>
this is what i got:
result
how do i get the submit button to right position and the glyphicons heights the same as the input fields what am i doing wrong?
I made some edits to your html : https://jsfiddle.net/05t4s041/
<form id="form" method="post" class="form-inline" >
<div class="row">
<div class="col-md-2">
<label for="from">from:</label>
<input type="text" class="form-control form-text" />
</div>
<div class="col-md-2">
<label for="to">to:</label>
<input type="text" class="form-control form-text"/>
</div>
<div class="col-md-2">
<label for="checkin">check in</label>
<div class="input-group date" id="datepicker">
<input type="text" class="form-control datepicker" name="processdate" />
<span class="input-group-addon btn"><i class="glyphicon glyphicon-calendar"></i> </span>
</div>
</div>
<div class="col-md-2">
<label for="checkout">check out</label>
<div class="input-group date" id="datepicker">
<input type="text" class="form-control datepicker" name="processdate" />
<span class="input-group-addon btn"><i class="glyphicon glyphicon-calendar"></i> </span>
</div>
</div>
<div class="col-md-2">
<input type="submit" class="btn btn-default" value="submit"/>
</div>
</div>
</form>
you could put divs with bootstrap classes around your label and control like:
<div class="col-md-2">
<div class="row">
<div class="col-md-6">
<label for="from">from:</label>
</div>
<div class ="col-md-6">
<input type="text" class="form-control form-text" />
</div>
</div>
</div>
The row div may be sufficient: it put's elements in a row put I like to put extra bootstrap classes around my controls so I can modify them. For example that the label has a smaller width than the control itself.

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

decrease input width (using bootstrap)

I am trying to decrease middle name input field but i can't get it work. It only works at xs screen (picture below).
<div class="row">
<form class="form-inline" role="form" name="userForm" novalidate>
<div class="form-group required">
<label for="first" class="control-label">Child's Name</label>
<div class="input-group">
<span class="col-xs-9 col-sm-5">
<input type="text" class="form-control" id='first' name="first" >
<label for ="first">First </label>
</span>
</div>
<div class="input-group">
<span class="col-xs-3 col-sm-2">
<input type="text" class="form-control col-xs-3 col-sm-2" id='mi' name="mi" >
<label for ="mi">MI</label>
</span>
</div>
<div class="input-group">
<span class="col-xs-9 col-sm-5">
<input type="text" class="form-control" id = "last" name="last" >
<label for="last"> Last </label>
</span>
</div>
</div>
</form>
</div>
You're code is wrong please check again.you end the </form> before end other tag. and again read how to use bootstrap form. help this link.
remove span and add col-sm-4 to div
`
<div class="form-group required">
<label for="first" class="control-label">Child's Name</label>
<div class="input-group col-sm-4">
<input type="text" class="form-control" id='first' name="first">
<label for="first">First </label>
</div>
<div class="input-group col-sm-1">
<input type="text" class="form-control " id='mi' name="mi">
<label for="mi">MI</label>
</div>
<div class="input-group col-sm-4">
<input type="text" class="form-control " id="last" name="last">
<label for="last"> Last </label>
</div>
<div class="help-block" ng-messages="userForm.first.$error" style="color:maroon" role="alert">
<p ng-message="required">Child's First Name is required.</p>
</div>
</div>
<div class="form-group">
<button type="submit" class="btn btn-danger">Submit</button>
</div>
</form>`

Fixed length of span size in input form

I have a form with some input tags and for each of it(I'm using bootstrap). I would like to use span with backgroud coloro but I have a problem with the size of it, because depends of text length (the best way is to use awesome, but I don't find icons useful to my purpose).
Is there a way to fix the width of the grey part of div? I tried with width, like the image, but it resize all the input fields.Thanks
<div class="row">
<!-- Fleet fields -->
<div class="col-xs-6">
<div class="panel panel-default">
<div class="panel-heading">
<i class="fa fa-car fa-fw"></i> Fleet inputs
</div>
<!-- /.panel-heading -->
<div class="panel-body">
<form role="form">
<div class="form-group input-group">
<span class="input-group-addon">Ap</span> <input type="text"
class="form-control" placeholder="Application">
</div>
<div class="form-group input-group">
<input type="text" class="form-control" placeholder="Cubic">
<span class="input-group-addon">cm<sup>3</sup></span>
</div>
<div class="form-group input-group">
<input type="number" class="form-control" placeholder="Power">
<span class="input-group-addon">H P</span>
</div>
<div class="form-group input-group">
<span class="input-group-addon">Eu</span> <input type="text"
class="form-control" placeholder="Euro class">
</div>
<div class="form-group input-group">
<span class="input-group-addon">Et</span> <input type="text"
class="form-control" placeholder="Engine type">
</div>
<div class="form-group input-group">
<span class="input-group-addon">Tr</span> <input type="text"
class="form-control" placeholder="Traction">
</div>
<div class="form-group input-group">
<span class="input-group-addon">Ts</span> <input type="text"
class="form-control" placeholder="Transmission">
</div>
<div class="form-group">
<label>Note</label>
<textarea class="form-control" rows="2" maxlength="100"></textarea>
</div>
</form>
</div>
<!-- /.panel-body -->
</div>
</div>
Css of input -group-addon
.input-group-addon{color:#3c763d;background-color:#dff0d8;border-color:#3c763d}
you can use for fixed width of grey part of div
you can use for fixed width of grey part of div
1.<div class="input-group input-group-lg"> <span class="input-group-addon" id="sizing-addon3">#</span> <input type="text" class="form-control" placeholder="Username" aria-describedby="sizing-addon3"> </div>
2. can use also another div <div class="input-group input-group-sm">
3. can use also <div class="input-group">
for the Icon you can use Class="fa fa-edit" or Class="glyphicon glyphicon-pencil"
for the Icon you can use Class="fa fa-edit" or Class="glyphicon glyphicon-pencil"

Bootstrap 3: Set custom width with input-group/input-group-addon and horizontal labels

I would like to control the size of my input elements using the class .col-lg-* outlined here on the bootstrap website. However, putting the <span> element inside of a div completely messes it up:
HTML with div:
<div class="input-group input-group-lg">
<label for="" class="control-label">Paycheck</label>
<div class="col-lg-10">
<span class="input-group-addon">$</span>
<input type="text" class="form-control" id="">
</div>
</div>
How can I set the width of the input elements so that they are all the same?
I want the left margin of each input element to be flush like so:
This is what it looks like now:
This is my current HTML:
<div class="col-md-6">
<div class="content">
<h2>Income</h2>
<form class="form-income form-horizontal" role="form">
<div class="input-group input-group-lg">
<label for="" class="control-label">Paycheck</label>
<span class="input-group-addon">$</span>
<input type="text" class="form-control" id="">
</div>
<div class="input-group input-group-lg">
<label for="" class="control-label">Investments</label>
<span class="input-group-addon">$</span>
<input type="text" class="form-control" id="">
</div>
<div class="input-group input-group-lg">
<label for="" class="control-label">Other</label>
<span class="input-group-addon">$</span>
<input type="text" class="form-control" id="">
</div>
<button class="btn btn-lg btn-primary btn-block" type="submit">Update</button>
</form>
</div>
LIVE EXAMPLE: http://jsfiddle.net/jfXUr/
As per my comment above, try grouping the label and .input-group together with a .form-group container.
<div class="form-group">
<label for="" class="control-label">Paycheck</label>
<div class="input-group input-group-lg">
<span class="input-group-addon">$</span>
<input type="text" class="form-control" id="">
</div>
</div>
Demo here - http://jsfiddle.net/jfXUr/1/