JQuery UI自动完成(1.8)滚动

And*_*mos 23 jquery scroll jquery-ui jquery-scrollable jquery-ui-autocomplete

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

这是我试过的:

  • jquery-ui-1.8.16.css我设置这个:
ui.autocomplete{
    max-height: 100px;
    overflow-y: auto;
    overflow-x: hidden;
}
Run Code Online (Sandbox Code Playgroud)

*如ui-documentation示例中所示

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

$("#myInput").autocomplete({
    source: mySource,
    minLength: 0,
});
Run Code Online (Sandbox Code Playgroud)

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

Nic*_*tti 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>
Run Code Online (Sandbox Code Playgroud)

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