Jquery select2 css height problem fixed
hardyweb

hardyweb @hardyweb

About: Highly motivated and self-directed IT professional with a strong foundation in web development (particularly Laravel) and a passion for continuous learning.

Location:
Terengganu, Malaysia
Joined:
Jun 20, 2022

Jquery select2 css height problem fixed

Publish Date: Sep 4 '24
3 4

insert this code

.select2-selection__rendered {
    line-height: 35px !important;
}
.select2-container .select2-selection--single {
    height: 37px !important;
    width: 100% !important;
}
.select2-selection__arrow {
    height: 37px !important;
}

Enter fullscreen mode Exit fullscreen mode

Comments 4 total

  • KeduConsultingServices
    KeduConsultingServicesJul 13, 2025

    It's did nothing. My Select2 picker remains the same height. Doesn't match Bootstrap theme at all.

    • hardyweb
      hardywebJul 13, 2025

      where did you put this code .select2-selection_rendered {
      line-height: 35px !important;
      }
      .select2-container .select2-selection--single {
      height: 37px !important;
      width: 100% !important;
      }
      .select2-selection
      _arrow {
      height: 37px !important;
      }

      • KeduConsultingServices
        KeduConsultingServicesJul 13, 2025

        In the CSS file associated with my partial class. I used the Dev tools to make sure that the CSS was loaded correctly.

        • hardyweb
          hardywebJul 13, 2025

          put in custom.css , this custom.css below select2.min.css

          /* Overwrite container height and width */
          .select2-container .select2-selection--single {
            height: 37px !important;
            width: 100% !important;
            display: flex !important;
            align-items: center !important;
          }
          
          /* Text inside select box */
          .select2-container .select2-selection--single .select2-selection__rendered {
            line-height: 35px !important;
            padding-left: 10px !important;
          }
          
          /* Dropdown arrow */
          .select2-container .select2-selection--single .select2-selection__arrow {
            height: 37px !important;
            top: 0 !important;
          }
          
          Enter fullscreen mode Exit fullscreen mode
Add comment