How to have a Label surrounded by two select boxes in Twitter Bootstrap - css

I am looking to have the following html render a select box, then a label, then another select box all in one row while using twitter bootstrap 2.0 What css could I add to bootstrap to accomplish this?
<div class="row">
<select class="span4"></select>
<label class="span4">UCA</label>
<select class="span4"></select>
</div>

I ultimately decided on this
<div class="row-fluid form-inline">
<select class="span4"></select>
<div class="span4 pagination-centered">#displayTag</div>
<select class="span4"></select>
</div>

Try taking a look at using the pull-left or pull-right classes.
<div class="row">
<select class="span4 pull-left"></select>
<label class="span4 pull-left">UCA</label>
<select class="span4 pull-left"></select>
</div>

Related

Button position middle row on form-inline Bootstrap 4

I'm making a form-inline using Bootstrap 4, but when I use a button, the position of the button is always at the top of the row, I want the button's position to be the same as the input field's position, which is in the middle of the row.
<form role="form" id="form_tambah_kriteria" class="margin-bottom-0">
<div class="form-row">
<div class="form-group col-md-4">
<label>Tipe Decision Maker</label>
<div class="input-group">
<div class="input-group-append"><span class="input-group-text"><i class="ion-ios-contacts"></i></span></div>
<input type="text" name="tipe_dm[]" class="form-control" placeholder="Tipe Decision Maker">
</div>
</div>
<div class="form-group col-md-4">
<label>Owned by:</label>
<div class="input-group">
<select class="form-control" name="owner_dm">
<option value="">0</option>
<option value="1">1</option>
</select>
</div>
</div>
<button class="btn btn-danger">Delete</button>
</div>
</form>
The following is Codepen
The simple fix is to wrap the button in a form-group and prefix it with some invisible text ( or <br />). But it would be dead wrong, just a handy hack, because it would simply hide the underlying problem with your codepen.
The proper fix would be to:
use latest stable version of Bootstrap - your pen currently uses v4.0.0-alpha5 which doesn't contain a lot of bugfixes and, among others, does not contain Bootstrap's flexbox classes)
wrap the button in a .form-group.col-md-4
use d-flex align-items-end classes on the .form-row
Working example: https://codepen.io/andrei-gheorghiu/pen/KKKNxZg
Note: until you start using the latest stable version of Bootstrap's CSS, you'll keep running into problems which seemingly don't make any sense, because the version you're using is a pre-release which does not include a lot of what most Bootstrap 4 examples take for granted.
the solution is easy just add <br> before the button Delete for new line...like this:
<br> <button class="btn btn-danger">Delete</button>
You should put the button in the third column grid and use the <br /> .
you should do it as below:
<div class="form-group col-md-4">
<br />
<button class="btn btn-danger">Delete</button>
</div>

Bootstrap input labels on left of input (rather than on top)

I am fairly new to Bootstrap and I'm trying to make a simple form, all elements of which are in a single line on the screen. My html code for the form looks something like this:
<form class="form-horizontal">
<fieldset>
<div class="form-container">
<div class="form-group">
<label>Search by:</label>
<input class="form-control" type="text">
</div>
<div class="form-group">
<label>Something:</label>
<input class="form-control" type="text">
</div>
</div>
</fieldset>
</form>
By default, the labels for my input fields appear about the input fields. I want them to be on the left side of the input fields. I've googled and checked on here how to implement this, but none of the solutions I found have worked (I tried adding classes to my form and changing their CSS, and tried using bootstrap's form-inline functionality).
Does anyone know how I could make the form look how I want it to look?
You will want to make two modifications to each form group in order to utilize the bootstrap grid system.
not sure which version of BS you are using but for grid it is the same concept: https://v4-alpha.getbootstrap.com/layout/grid/
You will want to use bootstrap grid system to define that the label and input on are the same line. Keep in mind that there are 12 columns in 1 row so items you want to be on the same line must add up to 12.
Add the following classes to your label: "col-lg-2 col-md-2 col-sm-2 control-label"
Wrap your input in a div and add the following classes: "col-lg-10 col-md-10 col-sm-10"
You will notice that between these two elements, the columns add up to 12 so in the bootstrap grid system, they will be on the same line.
(I also wrapped this in a container just for a more tidy display on this post)
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
<link rel="stylesheet" type="text/css" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">
<div class="container">
<form class="form-horizontal">
<fieldset>
<div class="form-container">
<div class="form-group">
<label class="col-lg-2 col-md-2 col-sm-2 col-xs-2 control-label">Search by:</label>
<div class="col-lg-4 col-md-4 col-sm-4 col-xs-4">
<input class="form-control" type="text">
</div>
<label class="col-lg-2 col-md-2 col-sm-2 col-xs-2 control-label">Something:</label>
<div class="col-lg-4 col-md-4 col-sm-4 col-xs-4">
<input class="form-control" type="text">
</div>
</div>
</div>
</fieldset>
</form>
</div>

How to make text visible on small screen resolutions like 1366 x 768 using bootstrap?

I am using bootstrap columns where i have a problem with screen resolution, Below select field text is not visible completely when i used screen resolution 1366 x 786.
How can i resolve this issue using bootstrap ?
main.html
<div class="row">
<div class="col-md-6 fieldHeight">
<div class="form-group">
<label for="oplossValDate" class="col-md-5 {{requiredstr}}">
OpLoss Validation Dates:</label>
<div class="col-md-7" ng-if="rcsaCycleDTO.cycStatLkupCode === 'RA_CYC_SETUP'">
<select class="form-control" name="oplossValDate"
id="oplossValDate"
ng-model="rcsaCycleDTO.opLossValidationDateKey"
ng-change="OplossFromAndToDate()"
ng-options="OplossValidationDateOption.id as OplossValidationDateOption.text for OplossValidationDateOption in OplossValidationDateOptions">
<option value="">Select...</option>
</select>
</div>
<div class="col-md-6 fieldHeight">
//code for these columns
</div>
</div>
Use the form tag around you <div class="form-group"> and remove the class="col-md-5" and class="col-md-7" like that:
<div class="row">
<div class="col-md-6 fieldHeight">
<form class="form-inline">
<div class="form-group">
<label for="oplossValDate" class="{{requiredstr}}">
OpLoss Validation Dates:</label>
<select class="form-control" name="oplossValDate"
id="oplossValDate"
ng-if="rcsaCycleDTO.cycStatLkupCode === 'RA_CYC_SETUP'"
ng-model="rcsaCycleDTO.opLossValidationDateKey"
ng-change="OplossFromAndToDate()"
ng-options="OplossValidationDateOption.id as OplossValidationDateOption.text for OplossValidationDateOption in OplossValidationDateOptions">
<option value="">Select...</option>
</select>
<div class="col-md-6 fieldHeight">
//code for these columns
</div>
</div>
</form>
see here for more information.
I prefer this site for all kind of code doubt: http://www.w3schools.com/bootstrap/bootstrap_grid_system.asp

bootstrap form-group vs row CSS which one prefer

I have used row and now using form-group CSS.
I am confused between these 2, which one should I prefer if I want to build form controls. Seems like both do same job.
I usually follow this pattern:
<div class="form-group">
<div class="row">
<div class="col-md-6"></div>
<div class="col-md-6"></div>
</div>
</div>
Note the col-md-6 and col-md-5 are examples and you can use any col-md-x class with unlimited number. just sum MUST be 12.
The direct answer to your question is in the documentation:
".form-row" is a variation of our standard grid class ".row" which overrides the
default column gutters for tighter and more compact layouts
See here: https://getbootstrap.com/docs/4.0/components/forms/#form-grid
This is for Bootstrap.
form-group per set of controls on a form. If your row has multiple cols, and each col has a label and an input text, put a form-group around each label and input control, such as:
<div class="row">
<div class="col-6">
<div class="form-group">
<label>Client Name: </label>
<input type="text" name="clientName" />
</div>
</div>
<div class="col-6">
<div class="form-group">
<label>Client Email: </label>
<input type="text" name="clientEmail />
</div>
</div>
</div>
... etc.

<input> is not clickable with Bootstrap 3 and col-md rows

I have some "col-md-12" divs on forms that appear to "cover" preceding inputs such that they are not clickable.
I have created a bootply with Bootstrap 3.0.0 to illustrate the issue. unclickable inputs
If I make the same bootply with bootstrap 3.0.3 then the input fields are now accessible clickable inputs
What I want to know is whether this is a bootstrap bug that has been fixed or whether my layout is breahing some rule or other?
you need to put your cols into a div with the row class
<form>
<div class="row"> // HERE
<div class="col-md-6">
<label class="control-label col-md-4">Home Phone:</label>
<div class="col-md-8">
<input id="contact_detail_home_phone" name="contact_detail[home_phone]" size="30" type="text" value="123 5668" class="form-control">
</div>
</div>
<div class="col-md-6">
<label class="control-label col-md-4">Work Phone:</label>
<div class="col-md-8">
<input id="contact_detail_work_phone" name="contact_detail[work_phone]" size="30" type="text" value="582 5135" class="form-control">
</div>
</div>
</div>
<div class="row"> // AND HERE
<div class="col-md-12">
<label class="control-label">Notes:</label>
<textarea cols="40" id="contact_detail_notes" name="contact_detail[notes]" rows="4" class="form-control"></textarea>
</div>
</div>
</form>
If you use medium size columns col-md- you can only have total 12 column units per each <div class=row>.
So, don't put more than total 12 units of col-md instead one row.
I assume this is limitation of doing layouts with columsn, floating divs and web page rendering legacy.

Resources