3

我的 aspx 文件中有一个 DropDownList,如下所示:

<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的解决方案。

感谢您的回复!

4

2 回答 2

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>
于 2011-08-04T08:48:24.977 回答
3

添加以下样式将根据需要对齐数字,但会将下拉箭头向左移动而不是向右移动。

除了使用它之外,我认为无法右对齐选择选项可能是 Chrome 中的一个限制。

.drop-down-list
{
    direction: rtl;
}
于 2011-08-04T08:51:00.977 回答