2011-04-19 111 views
1

我很高兴使用这个自动完成:http://code.google.com/p/jquery-autocomplete/jquery-autocomplete(standalone)设置宽度

我需要更改生成的UL列表的宽度,但通过CSS不能做到这一点:

.acResults { 
    width: 348px; 
} 

似乎宽度按照设定的时间的JavaScript每一个结果被生:

$('.acResults').width(348); 

工作,但只有一次(键入后覆盖)。 我已经尝试在“showResult”和“onItemSelect”中使用上述函数,但之后都立即覆盖它们。

在此先感谢。

回答

1

您可以使用!important修复风格,但这不是一个好习惯。例如:

.acResults { 
    width: 348px !important; 
} 
0

只是删除(或改变)线在本地设置该列表的宽度插件,即副本:

extraWidth = this.dom.$results.outerWidth() - this.dom.$results.width(); 
this.dom.$results.width(this.dom.$elem.outerWidth() - extraWidth); 

你可以将其更改为:

this.dom.$results 
    .width(Math.max(this.dom.$elem.outerWidth() - extraWidth, 348)); 

如果您使用缩小版本,请抓取未缩小版本,改变它,并通过您选择的缩小器运行。

或者,您可以创建一个修补程序,该修补程序会接收最小列表宽度选项并将其提交给dylan.verheul,或者可能会在issues page上提交新的功能请求。

+0

我不喜欢编辑插件本身,但我会提出一个问题。 – 2011-04-20 08:06:55

+1

感谢您提交问题! – dyve 2011-04-26 05:52:38

0

只是增加了“ac_results”的宽度,它会隐藏在y溢出

.ac_results ul { 
width: 180px; 
/* 
increase width to hide overflow 
*/ 
list-style-position: outside; 
list-style: none; 
padding: 0; 
margin: 0; 

}