$(function() {
var availableTags = [
"ActionScript",
"AppleScript",
"Asp",
"BASIC",
"C",
"C++",
"Clojure",
"COBOL",
"ColdFusion",
"Erlang",
"Fortran",
"Groovy",
"Haskell",
"Java",
"JavaScript",
"Lisp",
"Perl",
"PHP",
"Python",
"Ruby",
"Scala",
"Scheme"];
$("#tags").autocomplete({
source: availableTags
});
$("#tags2").autocomplete({
source: availableTags
});
$("#tags3").autocomplete({
source: availableTags
});
$("#tags2").autocomplete("widget").addClass('fixed-height');
$("#tags3").autocomplete("widget").attr('style', 'max-height: 400px; overflow-y: auto; overflow-x: hidden;')
});
.ui-autocomplete {
max-height: 100px;
overflow-y: auto;
/* prevent horizontal scrollbar */
overflow-x: hidden;
}
/* 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;
}
.fixed-height {
\t \t \t padding: 1px;
\t \t \t max-height: 200px;
\t \t \t overflow: auto;
\t \t }
<link href="https://cdnjs.cloudflare.com/ajax/libs/jqueryui/1.11.2/jquery-ui.css" rel="stylesheet"/>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jqueryui/1.11.2/jquery-ui.js"></script>
<div class="ui-widget">
<label for="tags">Tags max-height set with class .ui-autocomplete:</label>
<input id="tags" />
</div>
<div class="ui-widget">
<label for="tags">Tags max-height set manually with class fixed-height:</label>
<input id="tags2" />
</div>
<div class="ui-widget">
<label for="tags">Tags max-height set with jQuery:</label>
<input id="tags3" />
</div>
這是事實,但他們似乎正在尋找有不同的最大爲每彈出,這種方法會改變最大爲所有它不會?也認爲它更好地添加另一個.css文件並覆蓋,以便用nuget更新jQuery的css文件不會被跳過 – workabyte 2015-02-23 15:50:32
是的,它會。然後再一次,你必須唯一標識每個「自動完成」併爲它們分配高度 – 2015-02-23 15:55:13