0

I was trying to embeds three different forms in a single horizontal row.

The first(shop), second(locality) and third(search) form element should occupy 50%,30% and 20% (6,4 and 2 bootstrap col unit) of total horizontal row.

enter image description here

In mobile view, each three form element should be adjust in individual row. enter image description here I tried following:

<div class="row search-form-wizard">
    <form role="form" class="">
        <div class="form-group form-group-lg">
            <div class="col-md-6">
                <label class="sr-only" for="select2_sample6"></label>
                <input type="hidden" id="select2_sample6" class="form-control select2 input-lg"  >
            </div>
        </div>
        <div class="form-group form-group-lg">
            <div class="col-md-4">
                <label class="sr-only" for="selectextra_sample6"></label>
                <input type="hidden" id="selectextra_sample6" class="form-control select2 input-lg" >
            </div>
        </div>
        <div class="col-md-2">
            <button type="button" class="btn green btn-lg btn-block"><i class="fa fa-search"></i> Search</button>
        </div>
    </form>
</div>

Is this the correct approach?

Should I use bootstrap inline form for this purpose?

I tried using inline form, but its difficult to set width of each form elements.

2 Answers 2

2

You are correct you just need to adjust for small screens with col-xs-12 & change md to sm.. xs is mobile...

<div class="row search-form-wizard">
    <form role="form" class="">
        <div class="form-group form-group-lg">
            <div class="col-sm-6 col-xs-12">
                <label class="sr-only" for="select2_sample6"></label>
                <input type="hidden" id="select2_sample6" class="form-control select2 input-lg"  >
            </div>
        </div>
        <div class="form-group form-group-lg">
            <div class="col-sm-4 col-xs-12">
                <label class="sr-only" for="selectextra_sample6"></label>
                <input type="hidden" id="selectextra_sample6" class="form-control select2 input-lg" >
            </div>
        </div>
        <div class="col-sm-2 col-xs-12">
            <button type="button" class="btn green btn-lg btn-block"><i class="fa fa-search"></i> Search</button>
        </div>
     </form>
</div>
Sign up to request clarification or add additional context in comments.

2 Comments

with col-xs-12, there is no gap between three elements
This is where margins come into play.
1

You have to specify a small (col-sm-*) width for each one. Edit like another answer col-xs for extra-small screens.

<div class="col-md-6 col-sm-12">

<div class="col-md-4 col-sm-12">

<div class="col-md-2 col-sm-12">

3 Comments

col-xs-* is for mobile.
If you have applied custom margins, padding etc it can throw out the 12 grid system and you may have lose one of the 12 to handle it
That's why you apply margins and padding to inner elements not the column element itself.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.