Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Bootstrap select with BS4 input-group-prepend

I am using bootstrap 4 and bootstrap select version 1.13.2 (latest), which should support bootstrap 4. As mentioned in docs, i even manually specified BS verison via

$.fn.selectpicker.Constructor.BootstrapVersion = '4';

I wanted to have an icon next to the picker, i used following markup

<div class="form-group">
  <div class="input-group">
    <div class="input-group-prepend">
      <div class="input-group-text">
        <i class="fa fa-user"></i>
      </div>
    </div>
    <select id="internal-select-picker" class="form-control selectpicker" data-live-search="true" data-size="10" multiple>
      <option>option 1</option>
      <option>option 2</option>
      <option>option 3</option>
    </select>
  </div>                        
</div>

And the result is this, as you can see the icon is slightly larger than the select, i tried to apply different bs styles to both picker and icon group but nothing worked

enter image description here

Any suggestions how to resolve this issue will be appreciated

like image 662
Martin Avatar asked Aug 31 '18 09:08

Martin


People also ask

What is input group prepend in bootstrap?

Bootstrap 4 Input Groups input-group class is a container to enhance an input by adding an icon, text or a button in front or behind the input field as a "help text". Use . input-group-prepend to add the help text in front of the input, and . input-group-append to add it behind the input.

How do I add a calendar icon to the input field in bootstrap 4?

Open our free Bootstrap Form Builder in your browser. Add a field from the "Add a Field" tab. Select "Icon" from the Prepend or Append dropdown in the "Edit Fields" tab. Choose an icon from the icon picker window.

How do I make a small text box in bootstrap?

Use the . input-sm class to set small input field in Bootstrap.


1 Answers

I ended up coming up with my own fix by seeing what the Bootstrap CSS was doing to the drop down box and making my own classes to add fixes.

I added my own classes called fix-label-group and fix-label-item. See my jsfiddle below:

https://jsfiddle.net/ddschmitz/nkywb1xg/2/

like image 181
ddschmitz Avatar answered Oct 18 '22 17:10

ddschmitz