问题
I've been trying to do this by setting the size
attribute of the source select
element, but it's being ignored. There doesn't seem to any height setting option for the widget. Is it possible?
The widget is currently working inside a div dialog that has overflow hidden, so the drop-down (26 items, always) just disappears off the div.
回答1:
There is no size similar option in jQuery UI Selectmenu (aka show more than just a button but a select "pane"). But it's possible to change the height of the generated button by CSS.
Another idea would be changing the rendering mechanism like @Michael proposed.
A demo fiddle would be useful. When your actual issue is the overflow of the div you could try to add the menu to another element by using the appendTo option, see http://api.jqueryui.com/selectmenu/#option-appendTo
回答2:
How about some css...
.ui-selectmenu-open{
max-height: 350px;
overflow-y: scroll;
}
来源:https://stackoverflow.com/questions/24871504/is-it-possible-to-limit-the-height-of-a-selectmenu-widget-with-jquery-ui