Search code examples
bootstrap-4bootstrap-5

Bootstrap select input's width appears shorter than other inputs (text)


I am facing a weird peroblem in bootstrap. I am sharing an image of the inputs :

enter image description here

My codes are :

<div class="col-2 list_sidebar p-2">
    <div class="row">
       <div class="form-group">
           <input v-model="hospital_name" type="text" class="form-control" 
            placeholder="Hospital Name">
       </div>
    </div>
    <div class="row">
       <div class="form-group">
           <select class="form-control" v-model="district" 
                                   placeholder="District" @change="getThanaList">
                <option value="">Select District</option>
                <option v-for="(district, i) in districtList" :key="i" 
                                   :value="district.id">{{ district.title }}</option>
            </select>
        </div>
        <div class="form-group">
            <select v-model="thana" class="form-control">
                 <option value="">Select Thana</option>
                 <option v-for="(thana, t) in thanaList" :key="t" :value="thana.id">{{ 
                  thana.title }}</option>
            </select>
        </div>
        <div class="form-group">
             <button @click="searchRequest" type="submit" class="btn btn- 
              warning">Filter</button>
        </div>
    </div>
</div>  

I also tried putting them 100% width in css, but does not work


Solution

  • There are many things wrong in your code. First, by using bootstrap, you start with a row, and then inside that row you fit everything you want inside of it. You have a column, and then 3 rows.

    What you should do:

    <form class="row">
      <div class="col">
        first input
      </div>
      <div class="col">
        second input
      </div>
      <div class="col">
        third input
      </div>
      <div class="col">
        button
      </div>
    </form>
    

    And adapt that code with your style.