Fit div to inside contents - html

I have a background div that I use to create a "box" effect. I need this div to fit its contents but what I searched and tried to do, did not worked as expected. I'm using bootstrap.
I already tried in my div css:
display:inline-block;
display:inline-block !important;
This is my page without above css:
This is my page with above css
And this is what I need. My background "box" limit in the red line:
Page html:
<div class="input-content-boxed">
<div class="row">
<div class="col-md-4">
<div class="form-group form-group-default required">
<label>Nome</label>
<input asp-for="Name" class="form-control" />
</div>
</div>
<div class="col-md-2">
<div class="form-group form-group-default required">
<label>CNPJ</label>
<input id="txtCNPJ" asp-for="CNPJ" class="form-control" />
</div>
</div>
</div>
<div class="row">
<div class="col-md-3">
<div class="form-group form-group-default">
<label>País</label>
<select asp-for="Country" asp-items="new SelectList(ViewBag.Countries)" id="listCountry" data-init-plugin="select2" style="width: 100%">
</select>
</div>
</div>
<div class="col-md-3">
<div class="form-group form-group-default" id="divStateBrazil">
<label>Estado</label>
<select id="listStateBrazil" asp-items="new SelectList(ViewBag.BrazilStates)" data-init-plugin="select2" style="width: 100%">
</select>
</div>
<div class="form-group form-group-default" id="divStateEUA" hidden>
<label>Estado</label>
<select id="listStateEUA" asp-items="new SelectList(ViewBag.EUAStates)" data-init-plugin="select2" style="width: 100%">
</select>
</div>
<div class="form-group form-group-default" id="divStatePeru" hidden>
<label>Estado</label>
<select id="listStatePeru" asp-items="new SelectList(ViewBag.PeruStates)" data-init-plugin="select2" style="width: 100%">
</select>
</div>
</div>
</div>
<div class="row">
<div class="col-md-6">
<div class="form-group form-group-default">
<label>Cidade</label>
<input asp-for="City" class="form-control" />
</div>
</div>
</div>
<div class="row">
<div class="col-md-6">
<div class="form-group form-group-default">
<label>Logradouro</label>
<input asp-for="Street" class="form-control" />
</div>
</div>
</div>
<div class="row">
<div class="col-md-3">
<div class="form-group form-group-default">
<label>Bairro</label>
<input asp-for="District" class="form-control" />
</div>
</div>
<div class="col-md-3">
<div class="form-group form-group-default required">
<label>CEP</label>
<input id="txtCEP" asp-for="CEP" class="form-control" />
</div>
</div>
</div>
<div class="row">
<div class="col-md-3">
<div class="form-group form-group-default">
<label>Número</label>
<input asp-for="Number" class="form-control" />
</div>
</div>
<div class="col-md-3">
<div class="form-group form-group-default">
<label>Observação</label>
<input asp-for="Observation" class="form-control" />
</div>
</div>
</div>
<div class="row">
<div class="col-md-6">
<div class="form-group form-group-default required">
<label>Email</label>
<input asp-for="Email" class="form-control" />
</div>
</div>
</div>
<div class="row">
<div class="col-md-3">
<div class="form-group form-group-default required">
<label>Telefone</label>
<input id="txtPhone" asp-for="Phone" class="form-control" />
</div>
</div>
<div class="col-md-3">
<div class="form-group form-group-default">
<label>Celular</label>
<input id="txtCellphone" asp-for="Cellphone" class="form-control" />
</div>
</div>
</div>
</div>
Css:
.input-content-boxed {
background-color: #ffffff;
padding-left: 15px;
padding-right: 15px;
padding-bottom: 15px;
padding-top:15px;
border-radius: 3px;
box-shadow: 2px 2px 3px #888888;
display:inline-block;
}

The main issue I see is you're using the Bootstrap col- classes so your contents are being forced to fit in the grid. Specifically, it appears most the rows of your layout are only using 6 out of the 12 columns of the grid, which results in the form taking up only half the available width.
You'll want to make sure the col- classes add up to 12 for each row.
For the purposes of this demo I've used the col-xs- classes so the layout fits within the narrow demo frame below. You'll probably want to use the responsive classes to the form works well across more viewport sizes.
.input-content-boxed {
background-color: #ffffff;
padding-left: 15px;
padding-right: 15px;
padding-bottom: 15px;
padding-top:15px;
border-radius: 3px;
box-shadow: 2px 2px 3px #888888;
display:inline-block;
}
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet"/>
<div class="input-content-boxed">
<div class="row">
<div class="col-xs-8">
<div class="form-group form-group-default required">
<label>Nome</label>
<input asp-for="Name" class="form-control" />
</div>
</div>
<div class="col-xs-4">
<div class="form-group form-group-default required">
<label>CNPJ</label>
<input id="txtCNPJ" asp-for="CNPJ" class="form-control" />
</div>
</div>
</div>
<div class="row">
<div class="col-xs-6">
<div class="form-group form-group-default">
<label>País</label>
<select asp-for="Country" asp-items="new SelectList(ViewBag.Countries)" id="listCountry" data-init-plugin="select2" style="width: 100%">
</select>
</div>
</div>
<div class="col-xs-6">
<div class="form-group form-group-default" id="divStateBrazil">
<label>Estado</label>
<select id="listStateBrazil" asp-items="new SelectList(ViewBag.BrazilStates)" data-init-plugin="select2" style="width: 100%">
</select>
</div>
<div class="form-group form-group-default" id="divStateEUA" hidden>
<label>Estado</label>
<select id="listStateEUA" asp-items="new SelectList(ViewBag.EUAStates)" data-init-plugin="select2" style="width: 100%">
</select>
</div>
<div class="form-group form-group-default" id="divStatePeru" hidden>
<label>Estado</label>
<select id="listStatePeru" asp-items="new SelectList(ViewBag.PeruStates)" data-init-plugin="select2" style="width: 100%">
</select>
</div>
</div>
</div>
<div class="row">
<div class="col-xs-12">
<div class="form-group form-group-default">
<label>Cidade</label>
<input asp-for="City" class="form-control" />
</div>
</div>
</div>
<div class="row">
<div class="col-xs-12">
<div class="form-group form-group-default">
<label>Logradouro</label>
<input asp-for="Street" class="form-control" />
</div>
</div>
</div>
<div class="row">
<div class="col-xs-6">
<div class="form-group form-group-default">
<label>Bairro</label>
<input asp-for="District" class="form-control" />
</div>
</div>
<div class="col-xs-6">
<div class="form-group form-group-default required">
<label>CEP</label>
<input id="txtCEP" asp-for="CEP" class="form-control" />
</div>
</div>
</div>
<div class="row">
<div class="col-xs-6">
<div class="form-group form-group-default">
<label>Número</label>
<input asp-for="Number" class="form-control" />
</div>
</div>
<div class="col-xs-6">
<div class="form-group form-group-default">
<label>Observação</label>
<input asp-for="Observation" class="form-control" />
</div>
</div>
</div>
<div class="row">
<div class="col-xs-12">
<div class="form-group form-group-default required">
<label>Email</label>
<input asp-for="Email" class="form-control" />
</div>
</div>
</div>
<div class="row">
<div class="col-xs-6">
<div class="form-group form-group-default required">
<label>Telefone</label>
<input id="txtPhone" asp-for="Phone" class="form-control" />
</div>
</div>
<div class="col-xs-6">
<div class="form-group form-group-default">
<label>Celular</label>
<input id="txtCellphone" asp-for="Cellphone" class="form-control" />
</div>
</div>
</div>
</div>

Related

bootstrap 4 grid system doesnt float automatically

So I am developing a site using bootstrap 4 , everything works fine but the column that i have, need to be floated automatically , but it doesn't , is there any issue with bootstrap 4 or am i missing anything ,
As this can be solve too writing custom css but i do think i am missing something , please help .
<?php
include ("layouts/header.php");
?>
<section class="booking">
<div class="container">
<div class="row">
<div class="section-header">
<h2>Booking Procedures</h2>
</div>
<div class="section-content">
<div class="col-12">
<form>
<div class="card text-center">
<div class="card-header">
Booking Step 2 Of 2
</div>
<div class="card-block">
<p>All * fields are compulsory</p>
<div class="col-12 col-md-3">
<div class="form-group">
<select class="form-control">
<option>Title</option>
<option>Mr.</option>
<option>Mrs.</option>
<option>Miss</option>
</select>
</div>
</div>
<div class="col-12 col-md-3">
<div class="form-group">
<input type="text" class="form-control" placeholder="First Name *" />
</div>
</div>
<div class="col-12 col-md-3">
<div class="form-group">
<input type="text" class="form-control" placeholder="Middle Name" />
</div>
</div>
<div class="col-12 col-md-3">
<div class="form-group">
<input type="text" class="form-control" placeholder="Last Name *" />
</div>
</div>
<div class="col-12 col-md-3">
<div class="form-group">
<select class="form-control" required="required">
<option>Nationality</option>
<option>Chinese</option>
<option>Indian</option>
</select>
</div>
</div>
<div class="col-12 col-md-3">
<div class="form-group">
<input type="text" class="form-control datepicker" placeholder="Date Of Birth *" />
</div>
</div>
<div class="col-12 col-md-3">
<div class="form-group">
<input type="text" class="form-control" placeholder="Occupation" />
</div>
</div>
<div class="col-12 col-md-3">
<div class="form-group">
<input type="email" class="form-control" placeholder="Email Address *" />
</div>
</div>
<div class="col-12 col-md-3">
<div class="form-group">
<input type="text" class="form-control" placeholder="Detail Mailing Address *" />
</div>
</div>
<div class="col-12 col-md-3">
<div class="form-group">
<input type="text" class="form-control" placeholder="Mobile Number *" />
</div>
</div>
<div class="col-12 col-md-3">
<div class="form-group">
<input type="text" class="form-control" placeholder="Landline" />
</div>
</div>
<div class="col-12 col-md-3">
<div class="form-group">
<input type="text" class="form-control" placeholder="Passport Number *" />
</div>
</div>
<div class="col-12 col-md-3">
<div class="form-group">
<input type="text" class="form-control" placeholder="Place Of Issue *" />
</div>
</div>
<div class="col-12 col-md-3">
<div class="form-group">
<input type="text" class="form-control datepicker" placeholder="Date Of Issue *" />
</div>
</div>
<div class="col-12 col-md-3">
<div class="form-group">
<input type="text" class="form-control datepicker" placeholder="Date Of Expiry *" />
</div>
</div>
<div class="col-12 col-md-3">
<div class="form-group">
<select class="form-control" required="required">
<option>How did you find us</option>
<option>Friends</option>
<option>Family</option>
<option>Online</option>
<option>Travel Blog</option>
<option>Trip Advisor</option>
<option>Others</option>
</select>
</div>
</div>
<div class="col-12">
<div class="form-group">
<textarea class="form-control" placeholder="Emergency Contact * "></textarea>
</div>
</div>
</div>
<div class="col-12">
<p>Note: Please kindly note that you should be covered for, I- medical expenses, II- emergency air ambulance & III- Trip cancellation to plan this trip.</p>
</div>
<div class="col-12">
<div class="form-group">
<button type="submit" class="btn btn-sample3">Submit</button>
</div>
</div>
</div>
</form>
</div>
</div>
</div>
</div>
</section>
<?php include("layouts/footer.php"); ?>
Result i want
Result i got
Your code is not well formatted, you are using col- inside col- without the use of row. You need to have something like that
<div class="container" >
<div class="row">
<div class="col-12">
</div>
</div>
</div>
and to have nested row use this :
<div class="container" >
<div class="row">
<div class="col-12">
<div class="row">
<div class="col-12">
</div>
</div>
</div>
</div>
</div>
refer to the documentation :
https://getbootstrap.com/docs/4.0/layout/grid/#nesting

Apply borders to all fields and labels in a form

I need to style a bootstrap 3 form such as there is a border around each form field and label. Something like this -
I am not able to make out how to go about doing this. Here is my attempt to achieve this (Please expand the output so that you see 2 columns in each row) -
https://jsfiddle.net/yy7ddtby/15/
.custom-label {
line-height: 3.3em !important;
}
.label-size {
/*font-size: 10px;*/
line-height: 2.1em;
/*padding-right:0px;
width: 10%;*/
}
.border {
color: #555;
border: 1px solid #ccc;
border-radius: 1px;
padding: 5px;
}
<div class="container-fluid">
<form>
<div class="row">
<div class="col-md-6">
<div class="form-group">
<label for="name" class="col-md-4 label-size custom-label border">Name</label>
<div class="col-md-8 border">
<input type="text" id="name" class="form-control input-field">
</div>
</div>
</div>
<div class="col-md-6">
<div class="form-group">
<label for="gender" class="col-md-4 label-size custom-label border">Gender</label>
<div class="col-md-8 border">
<select id="gender" class="form-control input-field">
<option value="Male">Male</option>
<option value="Female">Female</option>
</select>
</div>
</div>
</div>
</div>
<div class="row">
<div class="col-md-6">
<div class="form-group">
<label class="col-md-4 label-size custom-label">Functions</label>
<div class="checkbox col-md-8 label-size">
<label>
<input type="checkbox" id="Func1"> Func1</label>
<label>
<input type="checkbox" id="Func2">Func2</label>
<label>
<input type="checkbox" id="Func3">Func3</label>
</div>
</div>
</div>
<div class="col-md-6">
<div class="form-group">
<label for="country" class="col-md-4 label-size custom-label">Country</label>
<div class="col-md-8">
<select id="country" class="form-control input-field">
<option>Select</option>
</select>
</div>
</div>
</div>
</div>
<div class="row">
<div class="col-md-6">
<div class="form-group">
<label for="options" class="col-md-4 label-size custom-label">Options</label>
<div class="col-md-8">
<select id="options" class="form-control input-field">
<option>Select</option>
</select>
</div>
</div>
</div>
<div class="col-md-6">
<div class="form-group">
<label for="addr" class="col-md-4 label-size custom-label">ADDR</label>
<div class="col-md-8">
<input type="text" id="addr" class="form-control input-field">
</div>
</div>
</div>
</div>
<div class="row">
<div class="col-md-6">
<div class="form-group">
<label for="author" class="col-md-4 label-size custom-label">Author</label>
<div class="col-md-8">
<input type="text" id="author" class="form-control input-field">
</div>
</div>
</div>
<div class="col-md-6">
<div class="form-group">
<label for="range1" class="col-md-4 label-size custom-label">Range1</label>
<div class="col-md-3">
<input type="text" id="range1" class="form-control input-field">
</div>
<div class="col-md-2">
to
</div>
<div class="col-md-3">
<input type="text" id="range2" class="form-control input-field">
</div>
</div>
</div>
</div>
<div class="row">
<div class="col-md-6">
<div class="form-group">
<label for="ip" class="col-md-4 label-size custom-label">IP</label>
<div class="col-md-8">
<input type="text" id="ip" class="form-control input-field">
</div>
</div>
</div>
</div>
</form>
</div>
I have tried to style the first row using a custom CSS called border. However, it doesn't look the way I want it to. The border it generates is quite untidy and not the way in the image.
How can I go about achieving the expected UI with borders?
I would actually give the entire row the border, then use left/right borders on the form elements to divide them up.
Here's the basic idea:
.row {
border: 2px solid black;
}
.form-group > label {
border-right: 2px solid black;
}
input {
border-right: 2px solid black;
}
revised demo

Bootstrap 3 - Two Column Layout - Get rid of placeholder

I am trying to create a form using bootstrap 3 that looks like
this.
I can get it to look pretty similar, but the only problem I have is that my last horizontal rule in the ETO section goes the entire way across. Is there any way I can make this only go across half of the page? I tried putting it in different col sizes inside that but I couldn't get it to work. Here's my html. Thanks ahead of time!
<div class="panel panel-default">
<div class="panel-heading">
<label style="color: white; font-weight: bold;">JOHNSON Summary</label>
</div>
<div class="panel-body">
<form class="form-horizontal" role="form" style="overflow-x:auto;">
<fieldset>
<div class="col-xs-6">
<div class="form-group">
<label class="col-xs-5"> Status </label>
<div class="col-xs-7">
<select class="form-control" id="empStatus">
<option value="" disabled>Choose Type....</option>
<option value="Current">Current</option>
<option value="Terminated">Terminated</option>
</select>
</div>
</div>
</div>
<div class="col-xs-6">
<div class="form-group">
<label class="col-xs-5"> Anniversary </label>
<div class="col-xs-7">
<input class='form-control' type="text" id="empAnniversary"/>
</div>
</div>
</div>
<div class="col-xs-6">
<div class="form-group">
<label class="col-xs-5"> Start Date </label>
<div class="col-xs-7">
<input class='form-control' type="date" id="empStartDate"/>
</div>
</div>
</div>
<div class="col-xs-6">
<div class="form-group">
<label class="col-xs-5"> Adjusted Start </label>
<div class="col-xs-7">
<input class='form-control' type="date" id="empAdjustedStart"/>
</div>
</div>
</div>
<div class="col-xs-6">
<div class="form-group">
<label class="col-xs-5"> STD/LTD </label>
<div class="col-xs-7">
<input class='form-control' type="text" id="empSTDLTD"/>
</div>
</div>
</div>
<div class="col-xs-6">
<div class="form-group">
<label class="col-xs-5"> Uncharged </label>
<div class="col-xs-7">
<input class='form-control' type="text" id="empUncharged"/>
</div>
</div>
</div>
</fieldset>
<fieldset>
<h4>PTO</h4>
<div class="col-xs-12">
<div class="form-group">
<div class="col-xs-1"></div>
<label class="col-xs-2"> Base </label>
<div class="col-xs-3">
<input class='form-control' type="text" id="ptoBase" />
</div>
<div class="col-xs-6">
</div>
</div>
</div>
<div class="col-xs-6">
<div class="form-group">
<label class="col-xs-2" style="font-weight: bold;"> + </label>
<label class="col-xs-4"> Carryover </label>
<div class="col-xs-6">
<input class='form-control' type="text" id="ptoCarryover" />
</div>
</div>
</div>
<div class="col-xs-6">
<div class="form-group">
<div class="col-xs-1"></div>
<label class="col-xs-4"> Balance </label>
<div class="col-xs-6">
<input class='form-control' type="text" id="ptoBalance" />
</div>
<div class="col-xs-1"></div>
</div>
</div>
<div class="col-xs-6">
<div class="form-group">
<label class="col-xs-2" style="font-weight: bold;"> ― </label>
<label class="col-xs-4"> Borrowed </label>
<div class="col-xs-6">
<input class='form-control' type="text" id="ptoBorrowed" />
</div>
</div>
<hr style="border: solid 1px black;border-bottom:1px solid black;clear:both" />
</div>
<div class="col-xs-6">
<div class="form-group">
<label class="col-xs-1" style="font-weight: bold;"> ― </label>
<label class="col-xs-4"> Requests </label>
<div class="col-xs-6">
<input class='form-control' type="text" id="ptoRequests" />
</div>
<div class="col-xs-1"></div>
</div>
<hr style="border: solid 1px black;border-bottom:1px solid black;clear:both" />
</div>
<div class="col-xs-6">
<div class="form-group">
<label class="col-xs-2" style="font-weight: bold;"> = </label>
<label class="col-xs-4"> Balance </label>
<div class="col-xs-6">
<input class='form-control' type="text" id="ptoBalance" />
</div>
</div>
</div>
<div class="col-xs-6">
<div class="form-group">
<label class="col-xs-1" style="font-weight: bold;"> = </label>
<label class="col-xs-4"> Available </label>
<div class="col-xs-6">
<input class='form-control' type="text" id="ptoAvailable" />
</div>
<div class="col-xs-1"></div>
</div>
</div>
</fieldset>
<fieldset>
<h4>ETO</h4>
<div class="col-xs-12">
<div class="form-group">
<div class="col-xs-1"></div>
<label class="col-xs-2"> Earned </label>
<div class="col-xs-3">
<input class='form-control' type="text" id="etoEarned" />
</div>
<div class="col-xs-6">
</div>
</div>
</div>
<div class="col-xs-12">
<div class="form-group">
<label class="col-xs-1"> ― </label>
<label class="col-xs-2"> Requests </label>
<div class="col-xs-3">
<input class='form-control' type="text" id="etoRequested" />
</div>
<div class="col-xs-6">
</div>
</div>
<hr style="border: solid 1px black;border-bottom:1px solid black;clear:both" />
</div>
<div class="col-xs-12">
<div class="form-group">
<label class="col-xs-1"> = </label>
<label class="col-xs-2"> Available </label>
<div class="col-xs-3">
<input class='form-control' type="text" id="etoAvailable" />
</div>
<div class="col-xs-6">
</div>
</div>
</div>
</fieldset>
</form>
</div>
</div>
UPDATED.
I think you need to use Bootstrap's horizontal form as described in official docs. It seems you are using horizontal form structure, but you've forgotten to add .form-horizontal class to your form element or to .form-group.

Bootstrap Control Layout Offset Issue

I have the following fiddle which is a cut down sample of a page I am working on utilising bootstrap for the styling.
NOTE: When viewing the fiddle, make sure the Result pane is wide enough to have the first 3 controls on a single row!
The issue that I have is that the 'Free Text Search' row of controls seem to be offset to the right more than I would like. I want the 'Free Text Search' label to be directly under the 'Store Number' label and the same width. Along with that I wand the corresponding input to start at the beginning of the 'Store Number' input and finish at the end of the 'Parent Category' select.
I can't quite see where I have gone wrong with the bootstrap classes.
Here is my html:
<form class="form-horizontal">
<h3 style="padding-left: 20px; padding-bottom: 20px">A pointless title</h3>
<div class="row form-group">
<div class="col-md-4">
<label for="storeNumber" class="col-sm-4 control-label">Store Number</label>
<div class="col-sm-6">
<input id="storeNumber" class="form-control" type="text"
name="storeNumber" placeholder="Store Number" />
</div>
</div>
<div class="col-md-4">
<label for="actionedTo" class="col-sm-4 control-label">Actioned To</label>
<div class="col-sm-6">
<select id="actionedTo" class="form-control"></select>
</div>
</div>
<div class="col-md-4">
<label for="parentCategory"
class="col-sm-4 control-label">Parent Category</label>
<div class="col-sm-6">
<select id="parentCategory" class="form-control"></select>
</div>
</div>
</div>
<div class="row form-group">
<div class="col-md-12">
<label for="freeTextSearch"
class="col-sm-2 control-label">Free Text Search</label>
<div class="col-sm-10">
<input id="freeTextSearch" class="form-control" type="text"
name="requestNumber" placeholder="Free Text Search" />
</div>
</div>
</div>
</form>
Your general structure is counter to your classes. You're structuring for your inputs to position inline but you're using form-horizontal and you're nesting columns.
You don't need any of that markup for this. Just use the form-group class and columns.
See working Snippet.
*The CSS I've added isn't needed to make everything work but I believe it looks better on larger viewports with it.
#media (min-width: 768px) {
.lg-group {
margin-top: 25px;
}
h3.form-title {
margin-bottom: 40px;
}
}
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.0.0/css/bootstrap.min.css" rel="stylesheet" />
<div class="container">
<nav class="navbar navbar-default">
<div class="navbar-header"> <a class="navbar-brand" href="#">Bootstrap 3 Header</a>
</div>
</nav>
</div>
<div class="container">
<div class="form-group">
<div class="col-sm-12">
<h3 class="form-title">A Pointless Title</h3>
</div>
</div>
<form class="myForm">
<div class="form-group">
<label for="storeNumber" class="col-sm-2 control-label">Store Number</label>
<div class="col-sm-2">
<input id="storeNumber" class="form-control" type="text" name="storeNumber" placeholder="Store Number" />
</div>
</div>
<div class="form-group">
<label for="actionedTo" class="col-sm-2 control-label">Actioned To</label>
<div class="col-sm-2">
<select id="actionedTo" class="form-control" name="actionedTo"></select>
</div>
</div>
<div class="form-group">
<label for="parentCategory" class="col-sm-2 control-label">Parent Category</label>
<div class="col-sm-2">
<select id="parentCategory" class="form-control" name="parentCategory"></select>
</div>
</div>
<div class="clearfix"></div>
<div class="form-group lg-group">
<label for="requestNumber" class="col-sm-2 control-label">Free Text Search</label>
<div class="col-sm-10">
<input id="freeTextSearch" class="form-control" type="text" name="requestNumber" placeholder="Free Text Search" />
</div>
</div>
</form>
</div>
Alternative Layout for Multiple Controls
#media (min-width: 768px) {
.lg-group {
margin-top: 25px;
}
h3.form-title {
margin-bottom: 40px;
}
}
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.0.0/css/bootstrap.min.css" rel="stylesheet"/>
<div class="container">
<nav class="navbar navbar-default">
<div class="navbar-header"> <a class="navbar-brand" href="#">Bootstrap 3 Header</a>
</div>
</nav>
</div>
<div class="container">
<div class="form-group">
<div class="col-sm-12">
<h3 class="form-title">A Pointless Title</h3>
</div>
</div>
<form class="myForm">
<div class="row">
<div class="col-sm-12">
<div class="lg-group">
<div class="form-group">
<label for="storeNumber" class="col-sm-2 control-label">Store Number</label>
<div class="col-sm-2">
<input id="storeNumber" class="form-control" type="text" name="storeNumber" placeholder="Store Number" />
</div>
</div>
<div class="form-group">
<label for="actionedTo" class="col-sm-2 control-label">Actioned To</label>
<div class="col-sm-2">
<select id="actionedTo" class="form-control" name="actionedTo"></select>
</div>
</div>
<div class="form-group">
<label for="parentCategory" class="col-sm-2 control-label">Parent Category</label>
<div class="col-sm-2">
<select id="parentCategory" class="form-control" name="parentCategory"></select>
</div>
</div>
</div>
</div>
</div>
<div class="row">
<div class="col-sm-12">
<div class="lg-group">
<div class="form-group">
<label for="storeNumber" class="col-sm-2 control-label">Store Number</label>
<div class="col-sm-2">
<input id="storeNumber" class="form-control" type="text" name="storeNumber" placeholder="Store Number" />
</div>
</div>
<div class="form-group">
<label for="actionedTo" class="col-sm-2 control-label">Actioned To</label>
<div class="col-sm-2">
<select id="actionedTo" class="form-control" name="actionedTo"></select>
</div>
</div>
<div class="form-group">
<label for="parentCategory" class="col-sm-2 control-label">Parent Category</label>
<div class="col-sm-2">
<select id="parentCategory" class="form-control" name="parentCategory"></select>
</div>
</div>
</div>
</div>
</div>
<div class="col-sm-12">
<div class="row">
<div class="form-group lg-group">
<label for="requestNumber" class="col-sm-2 control-label">Free Text Search</label>
<div class="col-sm-10">
<input id="freeTextSearch" class="form-control" type="text" name="requestNumber" placeholder="Free Text Search" />
</div>
</div>
</div>
</div>
</form>
</div>

How do I line up input fields with bootstrap?

I don't think I quite understand how bootstrap works with the grid. I want the name and actual field to match up unless the screen size is xs so every field is its own row. For each row, I want the text boxes always aligned.
Here's what I've tried.
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/css/bootstrap.min.css" rel="stylesheet"/>
<div class="container" style="width:80vw">
<form role="form">
<div class="row top-buffer">
<div class="col-sm-4 ">
<div class="form-group">
<label for="inputLabel3" class="col-sm-3 control-label">Date:</label>
<div class="col-sm-8">
<input type="date" class="form-control" id="inputLabel3" placeholder="date">
</div>
</div>
</div>
<div class="col-sm-4 ">
<div class="form-group">
<label for="inputname" class="col-sm-4 control-label">Name:</label>
<div class="col-sm-8 ">
<input type="text" class="form-control" id="name" placeholder="name">
</div>
</div>
</div>
<div class="col-sm-4">
<div class="form-group">
<label for="inputPassword" class="col-sm-3 control-label">Initials:</label>
<div class="col-sm-8">
<input type="text" class="form-control" id="inputInitials" placeholder="Initials">
</div>
</div>
</div>
</div>
<div class="row top-buffer">
<div class="col-sm-12">
<div class="form-group">
<label for="inputLabel3" class="col-sm-1 control-label">Title:</label>
<div class="col-sm-10 ">
<input type="text" class="form-control" id="inputLabel3" placeholder="title">
</div>
</div>
</div>
</div>
<div class="row top-buffer">
<div class="col-sm-5">
<div class="form-group">
<label for="inputLabel3" class="col-sm-2 control-label">Expected:</label>
<div class="col-sm-10 ">
<input type="number" class="form-control" id="inputLabel3" placeholder="title">
</div>
</div>
</div>
<div class="col-sm-5">
<div class="form-group">
<label for="Actual" class="col-sm-2 control-label">Actual:</label>
<div class="col-sm-10 ">
<input type="number" class="form-control" id="inputLabel3" placeholder="title">
</div>
</div>
</div>
</div>
</div>
<div class="row top-buffer">
<div class="col-sm-12">
<div class="form-group">
<label for="inputLabel3" class="col-sm-1 control-label">Description:</label>
<div class="col-sm-10 ">
<textarea id="descript" class="col-sm-10 "></textarea>
</div>
</div>
</div>
</div>
</div>
<!-- end container -->
</div
Bonus points for someone who can also help me make the description field larger - enough height for at least 20 new lines.
this includes the extra 20 spaces in despcription
Add this to your .css
.col-sm-4 {
display: inline-block;
vertical-align: middle;
float: none;
}
<div class="container" style="width:80vw">
<form role="form">
<div class="row top-buffer">
<div class="col-sm-4 ">
<div class="form-group">
<label for="inputLabel3" class="col-sm-3 control-label">Date:</label>
<div class="col-sm-8">
<input type="date" class="form-control" id="inputLabel3" placeholder="date">
</div>
</div>
</div>
<div class="col-sm-4 ">
<div class="form-group">
<label for="inputname" class="col-sm-4 control-label">Name:</label>
<div class="col-sm-8 ">
<input type="text" class="form-control" id="name" placeholder="name">
</div>
</div>
</div>
<div class="col-sm-4">
<div class="form-group">
<label for="inputPassword" class="col-sm-3 control-label">Initials:</label>
<div class="col-sm-8">
<input type="text" class="form-control" id="inputInitials" placeholder="Initials">
</div>
</div>
</div>
</div>
<div class = "row top-buffer">
<div class="col-sm-12">
<div class="form-group">
<label for="inputLabel3" class="col-sm-1 control-label">Title:</label>
<div class="col-sm-10 ">
<input type="text" class="form-control" id="inputLabel3" placeholder="title">
</div>
</div>
</div>
</div>
<div class = "row top-buffer">
<div class="col-sm-5">
<div class="form-group">
<label for="inputLabel3" class="col-sm-2 control-label">Expected:</label>
<div class="col-sm-10 ">
<input type="number" class="form-control" id="inputLabel3" placeholder="title">
</div>
</div>
</div>
<div class="col-sm-5">
<div class="form-group">
<label for="Actual" class="col-sm-2 control-label">Actual:</label>
<div class="col-sm-10 ">
<input type="number" class="form-control" id="inputLabel3" placeholder="title">
</div>
</div>
</div>
</div>
</div>
<div class = "row top-buffer">
<div class="col-sm-12">
<div class="form-group">
<label for="inputLabel3" class="col-sm-1 control-label">Description:</label>
<div class="col-sm-10 ">
<textarea id="descript" class="col-sm-10" rows="20"></textarea>
</div>
</div>
</div>
</div>
</div>
<!-- end container -->
</div