2014-01-23 147 views
3

我有選擇的標籤選項寬度的問題。我想 長文本不會導致選項超出選擇 標記的邊界。這種行爲可以在這個小提琴查看: http://jsfiddle.net/zono/KTu7x/5/ 這只是一個簡單的選擇標籤:的選擇選項設置寬度

<select id="myselect"> 
<option>short string</option> 
<option>long string long string long string</option>  
<option>short string</option> 
<option>short string</option> 
<option>short string</option> 
</select> 

我不想選擇,黑色的邊框(附圖片)以外去。 enter image description here

我希望得到任何幫助。

此致敬禮。

+0

你想幹什麼?省略號?例如:「long string long ...」 – RichieAHB

+0

要在第二行顯示的文本或者不可見的文本。文字中斷:全部打破;溢出:隱藏;選項選擇器根本沒有幫助。 –

+0

嗯,用純CSS,我認爲,你將無法改變這種行爲。你可以做的是重建與UL和李(http://stackoverflow.com/questions/8430279/how-to-style-the-option-with-only-css#8431078) – bouscher

回答

1
$("#testselectset").selectBoxIt({ 
      theme: "default", 
      defaultText: "Make a selection...", 
      autoWidth: false 
     }); 

您將無法保留選擇框的大小,但如果您使用了Selectboxit插件,則可以實現此目的。它使文本到達某個點後的選項標籤換行。以here爲例。我希望這有幫助!