2011-04-19 109 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; 

}