How to change the length of the select2 drop-down

11,049 views
Skip to first unread message

Don Proshetsky

unread,
Jun 18, 2014, 1:49:48 PM6/18/14
to sel...@googlegroups.com
Hi,

I have a select drop-down with 12 options; they all display when the drop-down is opened. Adfter using the Select2 widget on the drop-down, only 8 display and I am forced to scroll down to see the rest. The client does not like this and considers it unnecessary extra work for the users. How can I change this to display all available as long as it fits on the page?

Thanks / Don

Barry Hunter

unread,
Jun 18, 2014, 2:24:08 PM6/18/14
to sel...@googlegroups.com
The height of the 'dropdown' is set via

.select2-results {
    max-height: 200px;
}

in select2.css

So if you want to change it, just override it your own stylesheet (eg 400px). 



--
You received this message because you are subscribed to the Google Groups "select2" group.
To unsubscribe from this group and stop receiving emails from it, send an email to select2+u...@googlegroups.com.
To post to this group, send email to sel...@googlegroups.com.
Visit this group at http://groups.google.com/group/select2.
For more options, visit https://groups.google.com/d/optout.

Message has been deleted

jev...@panoramaed.com

unread,
Sep 16, 2015, 3:46:48 PM9/16/15
to select2
I just published a jQuery plugin that automatically expands the dropdown area to be as large as it needs to be to display as many options as possible given the size of the window and the location of the Select2 on the screen. You can see it here: https://github.com/panorama-ed/maximize-select2-height

rayy...@gmail.com

unread,
Oct 14, 2015, 11:14:35 AM10/14/15
to select2
You will need to change a bit more than just .select2-results

To make the drop down results larger you can add something like this to your own css after loading the default css.

.select2-container--default .select2-results > .select2-results__options {
max-height: 300px;
min-height: 200px;
overflow-y: auto;
}

In this example the drop down will size itself between the min and max values.

parva...@gmail.com

unread,
Oct 3, 2017, 4:45:41 PM10/3/17
to select2

Thanks .It works :)

Recep Yılkıcı

unread,
Mar 31, 2023, 2:30:43 AM3/31/23
to select2
You are great person. I searched a lot of pages on stackoverflow or github issues but I found the solution right here. Thank you so much.

Regards,

14 Ekim 2015 Çarşamba tarihinde saat 18:14:35 UTC+3 itibarıyla rayy...@gmail.com şunları yazdı:

nhan tam

unread,
Apr 5, 2024, 9:07:27 PM4/5/24
to select2
Working well

Vào lúc 22:14:35 UTC+7 ngày Thứ Tư, 14 tháng 10, 2015, rayy...@gmail.com đã viết:
Reply all
Reply to author
Forward
0 new messages