Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Options in select box not responsive

The options in my select field are not responsive .

enter image description here

I use a php loop to display options and I think the problem comes from there :

<div class="form-group">
      <label class="col-sm-2 control-label">Sélectionner un article</label>
            <div class="col-sm-10">
                 <select class="form-control m-b-sm" name="a_idarticle" id="a_idarticle">
                      <?php
                         foreach ($allarticles as $aa) {
                             echo '<option value="'.$aa['id_article'].'">'.$aa['id_article'].'--'.$aa['titre'].'</option>';
                         }
                      ?>
                </select>
         </div>
  </div>

Does anyone know a solution ?

like image 529
Sylvain Avatar asked Oct 30 '22 02:10

Sylvain


1 Answers

One solution could be the use of ellipsis

Try to change the CSS property for select and option attr in your form:

CSS:

#a_idarticle, #a_idarticle option {
     text-overflow: ellipsis;
}

References: Ellipsis for overflow text in dropdown boxes

Edit to add another solution: In addition, you could use a button to wrap the dropdown, like in this post: Setting the width of a dropdown list in Bootstrap 3.0

like image 137
Nacho M. Avatar answered Nov 09 '22 13:11

Nacho M.