TastyCode
TastyCode

Reputation: 5799

Bootstrap 3 - Removing too much space between input fields with a dash in between

I would like to have input boxes as:

enter image description here

but getting:

enter image description here

Is there any way i can remove the extra whitespace in between and get desired output without using css margins. My codes is as follows:

<div class="row">
    <div class="col-md-2 employerEin">
        <input type="text" name="employerEIN1" maxlength="2" size="2" value=""
               class="form-control" id="employerEIN1" title="EIN">
    </div>
    <span class="col-md-1 employerEin">-</span>
    <div class="col-md-3">
        <input type="text" name="employerEIN2" maxlength="7" size="7" value=""
               class="form-control" id="employerEIN2" title="EIN">
    </div>
</div>

Upvotes: 0

Views: 570

Answers (1)

timgavin
timgavin

Reputation: 5166

Just add the .form-inline class to your <form>

<div class="row">
    <form class="form-inline">
        <div class="form-group">
            <input type="text" name="employerEIN1" maxlength="2" size="2" value="" class="form-control" id="employerEIN1" title="EIN">
            -
            <input type="text" name="employerEIN2" maxlength="7" size="7" value="" class="form-control" id="employerEIN2" title="EIN">
        </div>
    </form>
</div>

EDIT: Added additional code due to OP's comment

Just add the .form-inline class to the enclosing div to make those two fields behave inline, then continue adding other fields as necessary

<div class="row">

    <!-- add the .form-inline class to the enclosing div -->
    <div class="form-group form-inline">
        <input type="text" name="employerEIN1" maxlength="2" size="2" value="" class="form-control" id="employerEIN1" title="EIN">
        -
        <input type="text" name="employerEIN2" maxlength="7" size="7" value="" class="form-control" id="employerEIN2" title="EIN">
    </div>

    <!-- add other form elements as needed -->
    <div class="form-group">
        <input type="text" name="field3" maxlength="2" value="" class="form-control">
    </div>
    <div class="form-group">
        <input type="text" name="field4" maxlength="7" value="" class="form-control">
    </div>

</div>

Upvotes: 2

Related Questions