2011-08-04 38 views
3

我有一個像這樣在我的aspx文件一個DropDownList:如何在DropDownList中爲ListItem設置對齊方式?

<asp:DropDownList runat="server" ID="MaxRec"> 
    <asp:ListItem>10</asp:ListItem> 
    <asp:ListItem>50</asp:ListItem> 
    <asp:ListItem>100</asp:ListItem> 
    <asp:ListItem>150</asp:ListItem> 
    <asp:ListItem Selected="True">200</asp:ListItem> 
</asp:DropDownList> 

在Chrome中它呈現這樣的:

DDL

我怎麼可以設置所有listItems中的對齊方式是正確的這樣值就能正確對齊? 我試着在DropDownList和ListItems上設置style =「text-align:right」,但它沒有任何效果。 我需要一個也適用於Chrome的解決方案。

感謝您的回覆!

回答

3

添加下面的樣式將調整爲所需的數字,但將在下拉箭頭移動到左邊,而不是權利。

除了使用這個,我認爲無法右對齊選擇選項可能是鉻的限制。

.drop-down-list 
{ 
    direction: rtl; 
} 
+0

+1酷,它的作品,但像你說的那樣把箭頭放在另一邊,我希望有一個更好的解決方案,雖然 –

3

下面的代碼對我的作品

<head> 
    <style type="text/css"> 
      select.myDropDownList { 
      text-align: right; 
      } 
     </style> 
</head> 


<asp:DropDownList ID="myDropDownList" Runat="server" CssClass="myDropDownList"> 
    <asp:ListItem>10</asp:ListItem> 
    <asp:ListItem>50</asp:ListItem> 
    <asp:ListItem>100</asp:ListItem> 
    <asp:ListItem>150</asp:ListItem> 
</asp:DropDownlist> 
+2

上述方法適用於很多瀏覽器,但不適用於chrome。 – jdavies

+0

@Shebin:這是我在帖子中說過的,但在Chrome中無法使用。 –

相關問題