【发布时间】:2010-08-25 07:26:00
【问题描述】:
在我的网络应用程序中,我在网页顶部的固定工具栏中有一个搜索框。 我这样实现了工具栏的固定位置......
#toolbar {
position: fixed !important;
position: absolute;
height: 25px;
width: 100%;
top: 0px;
left: 0px;
margin: 0;
z-index: 100;
font-size: 12px;
}
现在,我正在使用 a jQuery plugin 在其上实现关键字自动完成功能。
我的问题是如何在窗口滚动/调整大小时保持自动完成建议固定/附加到搜索框。
自动完成建议框的 css 是....
element.style {
display:none;
left:166px;
position:absolute;
top:96px;
width:130px;
}
.ac_results {
background-color:white;
border:1px solid #C5DBEC;
overflow:hidden;
padding:0;
z-index:99999;
}
我在执行这些操作时遇到问题..
- 在搜索框中输入内容,从而显示建议
- 搜索框打开后,我滚动窗口。
- 这会导致自动建议框也滚动。
我可以做些什么来解决这个错误?
这是它的外观。
自动完成已滚动到固定位置的输入框。
更新 1:我尝试将position: fixed; 添加到自动完成中。
这会在不同的情况下产生问题。
- 在搜索框中输入内容,从而显示建议
- 按退出键,导致该框消失
- 向下滚动窗口
- 在搜索框中输入内容,从而显示建议
- 现在搜索框出现在滚动前出现的位置,因为位置是固定的
更新:
更新 2:
以下添加到自动完成 css 的代码可以解决问题。
.ac_results {
background-color:white;
border:1px solid #C5DBEC;
overflow:hidden;
padding:0;
z-index:99999;
position: fixed;
top: 0px;
margin: 20px 0px 0px 0px; /* The top margin defines the offset of textbox */
}
问候
【问题讨论】:
-
我想,只有一个活生生的例子才能帮助我们帮助你。
标签: jquery css jquery-autocomplete