How to change the length of the select2 drop-down

瀏覽次數:10,684 次
跳到第一則未讀訊息

Don Proshetsky

未讀,
2014年6月18日 下午1:49:482014/6/18
收件者: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

未讀,
2014年6月18日 下午2:24:082014/6/18
收件者: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.

訊息已遭刪除

jev...@panoramaed.com

未讀,
2015年9月16日 下午3:46:482015/9/16
收件者: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

未讀,
2015年10月14日 上午11:14:352015/10/14
收件者: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

未讀,
2017年10月3日 下午4:45:412017/10/3
收件者:select2

Thanks .It works :)

Recep Yılkıcı

未讀,
2023年3月31日 凌晨2:30:432023/3/31
收件者: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

未讀,
2024年4月5日 晚上9:07:274月5日
收件者: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:
回覆所有人
回覆作者
轉寄
0 則新訊息