简体   繁体   中英

Select2: using bootstrap grid

I have the below code. It works but the input is small. I want it to look like any other Bootstrap input, ie. to fill the entire div container. I have installed the Bootstrap theme. I tryed to use .form-control class.

<div class="row">
  <div class="col-12 col-md-6">
    <select class="states" name="states[]" multiple="multiple">
      <option value="AL">Alabama</option>
      <option value="WY">Wyoming</option>
    </select>
  </div>
</div>
$(function() {
  $(".states").select2({
    theme: "bootstrap"
  });
});

Just use css .states{ width:100%; } .states{ width:100%; }

 .row { background-color:lightgray; } .states{ width:100%; }
 <link href="https://stackpath.bootstrapcdn.com/bootstrap/4.4.1/css/bootstrap.min.css" rel="stylesheet"/> <script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script> <script src="https://cdn.jsdelivr.net/npm/popper.js@1.16.0/dist/umd/popper.min.js"></script> <script src="https://stackpath.bootstrapcdn.com/bootstrap/4.4.1/js/bootstrap.min.js"></script> <div class="row"> <div class="col-md-12 col-md-6"> <select class="states" name="states[]" multiple="multiple"> <option value="AL">Alabama</option> <option value="WY">Wyoming</option> </select> </div> </div>

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM