JQuery UI自动完成(1.8)滚动

问题描述 投票:23回答:1

我在配置JQuery-UI的自动完成模块时遇到了麻烦。我需要当要选择的数据量足够大时会出现滚动条。

这是我试过的:

  • jquery-ui-1.8.16.css我设置了这个:
ui.autocomplete{
    max-height: 100px;
    overflow-y: auto;
    overflow-x: hidden;
}

*如ui-documentation示例所示

这是我声明和自动完成输入的方式:

$("#myInput").autocomplete({
    source: mySource,
    minLength: 0,
});

我不知道为什么滚动条没有出现,任何帮助将不胜感激。非常感谢你!

jquery jquery-ui scroll jquery-ui-autocomplete jquery-scrollable
1个回答
68
投票

您应该像这样覆盖在页面中设置它的CSS

<style>
.ui-autocomplete {
    max-height: 100px;
    overflow-y: auto;
    /* prevent horizontal scrollbar */
    overflow-x: hidden;
    /* add padding to account for vertical scrollbar */
    padding-right: 20px;
}
/* IE 6 doesn't support max-height
 * we use height instead, but this forces the menu to always be this tall
 */
* html .ui-autocomplete {
    height: 100px;
}
</style>

而不是改变jquery-ui-1.8.16.css中的值

© www.soinside.com 2019 - 2024. All rights reserved.