Is it possible to limit the height of a selectmenu

2019-03-03 23:30发布

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.

2条回答
Anthone
2楼-- · 2019-03-04 00:23

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

查看更多
你好瞎i
3楼-- · 2019-03-04 00:25

How about some css...

.ui-selectmenu-open{
        max-height: 350px;
        overflow-y: scroll;
    }
查看更多
登录 后发表回答