Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to set text right after textbox twitter bootstrap

I have a form elements using the following markup.. And the current look of the form you can find in the following screenshot:

Screenshot

How can I set the "In" and"Lbs" right after their corresponding textbox?

<div class="form-group">
    <label for="BI16" class="col-md-1 col-md-offset-1 control-label">Height:</label>
    <div class="col-md-1">
        <input type="text" id="BI16" name="medicareNumber" class="form-control" ng-model="hraFormData.HraValuesJson.BI16" />In
    </div>
    <label for="BI16" class="col-md-1 control-label">Weight:</label>
    <div class="col-md-1">
        <input type="text" id="BI16" name="medicareNumber" class="form-control" ng-model="hraFormData.HraValuesJson.BI16" />
    </div>
    <label for="BI16" class="col-md-1 control-label">BMI:</label>
    <div class="col-md-2">
        <input type="text" id="BI16" name="medicareNumber" class="form-control" ng-model="hraFormData.HraValuesJson.BI16" />Lbs
    </div>
    <label for="BI16" class="col-md-1 control-label">Waist:</label>
    <div class="col-md-2">
        <input type="text" id="BI16" name="medicareNumber" class="form-control" ng-model="hraFormData.HraValuesJson.BI16" />
    </div>
</div>
like image 238
Ammar Khan Avatar asked Mar 29 '14 15:03

Ammar Khan


People also ask

How do I align text to the right in bootstrap?

You can simply use the class . justify-content-between in combination with the class . d-flex to left align and right align text content within a <div> container in Bootstrap 4.

How do I center a label in bootstrap?

Add text-align: center in your CSS or text-center class to your parent element (probably to a row or container ).


1 Answers

You can use Bootstrap's input groups to attach the units to the inputs:

<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet"/>

<div class="form-group">
  <label for="BI16" class="col-md-1 col-md-offset-1 control-label">Height:</label>
  <div class="col-md-1">
    <div class="input-group">
      <input type="text" id="BI16" name="medicareNumber" class="form-control" ng-model="hraFormData.HraValuesJson.BI16" />
      <span class="input-group-addon">In</span>
    </div>
  </div>
  <label for="BI16" class="col-md-1 control-label">Weight:</label>
  <div class="col-md-1">
    <div class="input-group">
      <input type="text" id="BI16" name="medicareNumber" class="form-control" ng-model="hraFormData.HraValuesJson.BI16" />
      <span class="input-group-addon">Lbs</span>
    </div>
  </div>
  <label for="BI16" class="col-md-1 control-label">BMI:</label>
  <div class="col-md-2">
      <input type="text" id="BI16" name="medicareNumber" class="form-control" ng-model="hraFormData.HraValuesJson.BI16" />
  </div>
  <label for="BI16" class="col-md-1 control-label">Waist:</label>
  <div class="col-md-2">
      <input type="text" id="BI16" name="medicareNumber" class="form-control" ng-model="hraFormData.HraValuesJson.BI16" />
  </div>
</div>
like image 135
Ross Allen Avatar answered Sep 27 '22 23:09

Ross Allen