24

我在配置 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,
});

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

4

1 回答 1

71

你应该像这样覆盖页面中的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

于 2012-02-14T18:45:53.323 回答