2014-02-18 22 views
1

我嘗試使用Bootstrap雙列表框,從這裏:http://www.virtuosoft.eu/code/bootstrap-duallistbox/) 我的問題是,雙列表框始終對齊到左側, t改變它, 我嘗試寫入樣式屬性到'選擇'元素,並嘗試鏈接到CSS文件,但沒有任何工作。 這是代碼:無法更改'選擇'元素的位置(ASP.net)

<body> 

     <select id="sele" multiple="multiple" size="5" name="listbox" class='demo2 col-md-3' style="text-align:center"> 

     <% for(int i = 0 ; i <50; i++){ %> 
     <option value="<%=i %>" ><%=i %></option> 
     <% } %> 

    </select> 



    <script> 
     var demo2 = $('.demo2').bootstrapDualListbox({ 
      nonselectedlistlabel: 'Select', 
      selectedlistlabel: 'Selected', 
      preserveselectiononmove: 'moved', 
      moveonselect: false, 
      initialfilterfrom: '' 
     }); 
    </script> 
    <script src="libraries/jquery-placeholder/jquery.placeholder.js"></script> 
    <script> 
     $('input').placeholder(); 
     prettyPrint(); 
    </script> 
</body> 

這是怎麼看: http://oi57.tinypic.com/262up7r.jpg (而不是在中心) 我怎樣才能解決呢?

謝謝!

回答

0

嘗試在容器包裝,然後將其設置爲居中對齊,就像這樣:

<div style="width:100%; text-align:center;"> 
    <select id="sele" multiple="multiple" size="5" name="listbox" class='demo2 col-md-3'> 
     ... 
    </select> 
</div> 
0

在一個div容器包裝你<Select>並設置下列樣式到容器DIV:

display: table; 
margin: 0 auto; 

它應該是這個樣子,現在

<div style="display: table; margin: 0 auto;"> 

    <select id="sele" multiple="multiple" size="5" name="listbox" class='demo2 col-md-3'> 
     <!-- your stuff --> 
    </select> 

</div> 
+0

嗨, 元素向右移動,但仍然沒有到中心,此外列表寬度改變..(我嘗試改變寬度back ..但沒有幫助) 看起來像這樣: http://oi60.tinypic.com /2dshkjd.jpg 也許你有另一種解決方案? 謝謝!! – user3321263

+0

@ user3321263我的答案不適合你嗎? –