【发布时间】:2011-02-03 08:24:13
【问题描述】:
使用 jquery ui 1.8 尝试自动完成
除了 ui-menu 不在我的输入元素下方,而是在左上角之外,其他一切都有效。
有人遇到过这个问题吗?
这是我的html:
<div id="search">
<div id="searchFormWrapper">
<form method="post" name="searchForm" id="searchForm" action="/searchresults">
<label for="searchPhrase" id="searchFor">
Search for</label>
<input name="searchPhrase" id="searchPhrase" type="text" />
<label for="searchScope" id="searchIn">
in</label>
<select name="searchScope" id="searchScope">
<option value="">All Shops</option>
...
</select>
<input type="image" name="submitSearch" id="submitSearch" src="/images/buttons/search.gif"
alt="Search ..." />
</form>
<br class="clear" />
</div>
</div>
这是我的 CSS:
#search
{
width:100%;
margin:0;
padding:0;
text-align:center;
height:36px;
line-height:36px;
background:#666 url(/images/interface/info_bar_bg.gif) repeat-x top left;
overflow:hidden;
font-size:12px;
}
#searchFormWrapper
{
width:520px;
height:36px;
overflow:hidden;
margin:auto;
padding:0;
}
label#searchFor
{
display:block;
float:left;
width:80px;
padding:0 5px 0 0;
margin:0 0 0 0;
text-align:right;
}
label#searchIn
{
display:block;
float:left;
width:20px;
padding:0 5px 0 0;
margin:0 0 0 0;
text-align:right;
}
#searchPhrase
{
display:block;
float:left;
width:120px;
margin:7px 0 0 0;
padding:0;
}
#searchScope
{
display:block;
float:left;
width:120px;
margin:7px 0 0 0;
padding:0;
}
#submitSearch
{
display:block;
float:left;
margin:7px 0 0 10px;
padding:0;
}
这是我的 javascript:
$(document).ready(function()
{
$("#searchPhrase").autocomplete(
{
source: "/search?json",
minLength: 2
});
});
【问题讨论】:
-
您确定要包含 jQuery UI CSS 文件吗?
-
是的。检查了。 ui-menu 列表的格式都正确。只是位置不对...
-
您有要查看的版本的链接吗?我建议删除除自动完成的 CSS 之外的所有 CSS,以检查它是否有任何其他规则冲突。
-
好的,完成了(删除了所有其他 CSS),它仍然显示在左上角,而不是附加到输入元素......嗯......我猜这是向前迈出的一步...... .
标签: javascript css jquery-ui autocomplete