2011-01-12 116 views
1

我想爲自定義樣式的選擇框使用腳本,並且因爲我需要在選擇框之一中有足夠的條目,但我在創建滾動功能時被卡住了(一個腳本來計算數字項目,如果它在X上,那麼需要將一些Overflow屬性改爲腳本創建的UL。)對此的任何解決方案?自定義樣式的選擇框

回答

1

沒有這種溢出控制的直接選項,瀏覽器會自動管理文檔高度。

爲了做到這一點,您可以使用jQuery Dropdown Replacement並從您擁有的鏈接應用皮膚。

1

有一個很好的方法來做到這一點! ^^我做到了幾秒鐘前)

HTML

<div class="styledSelect"> 
       <span class="styledSelectValue"></span> 
       <select name="type"> 
        <option value="">Par type de propriété</option> 
        <option value="choix2">choix2</option> 
        <option value="choix3">choix3</option> 
       </select> 
      </div> 

CSS

.styledSelect{/*your css for the background image... it will be the body of your select*/} 
.styledSelect select{/*your css with opacity:0;*/} 
.styledSelectValue{/*the css of the received value*/} 

jQuery的

$('.styledSelect').each(function(){ 
      selectValue = $(this).children("select").val(); 
      if(selectValue == ""){selectValue = $(this).children("select").children("option:eq(0)").text();} 
      $(this).children(".styledSelectValue").text(selectValue); 
     }); 
     $('.styledSelect select').change(function(){ 
      selectValue = $(this).val(); 
      if(selectValue == ""){selectValue = $(this).children("option:eq(0)").text();} 
      $(this).parent(".styledSelect").children(".styledSelectValue").text(selectValue); 
     }); 

這是我找到的最好的方式;)