问题描述
我正在使用 Jquery UI 自动完成插件作为直接搜索词建议工具.除了我无法移动结果框外,它已启动并运行,没有任何问题.我基本上需要将它向左移动 20 像素,向下移动 4 像素.我试图覆盖 Jquery UI CSS,但无法重新定位框.
I am using the Jquery UI Autocomplete plugin for a straight forward search term suggestion tool. It is up and running with no problems except that I cannot move the results box. I basically need to move it 20 pixels to the left and 4 pixels down. I have attempted to overwrite the Jquery UI CSS, but have not been able to reposition the box.
非常感谢有此问题经验的人提供任何帮助.
Any help from someone experienced with this issue would be greatly appreciated.
推荐答案
这里有一种方法可以做到这一点,点击 open 事件并在该事件发生时更改菜单的位置:
Here's one way you could do it, tapping into the open event and changing the position of the menu when that event occurs:
$("#autocomplete").autocomplete({
appendTo: "#results",
open: function() {
var position = $("#results").position(),
left = position.left, top = position.top;
$("#results > ul").css({left: left + 20 + "px",
top: top + 4 + "px" });
}
});
我还使用 appendTo 选项来轻松查找包含菜单的 ul.不过,您可以在没有此选项的情况下执行此操作.
I'm also using the appendTo option to make finding the ul that contains the menu easily. You could do it without this option though.
这是一个工作示例:http://jsfiddle.net/9QmPr/
这篇关于重新定位 Jquery UI 自动完成结果框的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!



大气响应式网络建站服务公司织梦模板
高端大气html5设计公司网站源码
织梦dede网页模板下载素材销售下载站平台(带会员中心带筛选)
财税代理公司注册代理记账网站织梦模板(带手机端)
成人高考自考在职研究生教育机构网站源码(带手机端)
高端HTML5响应式企业集团通用类网站织梦模板(自适应手机端)