Is it possible to limit the height of a selectmenu widget with jQuery UI?

对着背影说爱祢 提交于 2019-12-20 07:23:34

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!