2015-12-21 24 views
0

我用我的web应用程序的下拉,但是当我跑,我看到文本对齐方式未设置为中心,我的下拉列表中的HTML代码是这样的:
为什么我的asp.net下拉列表文本对齐没有设置为中心?

<asp:DropDownList ID="DropDownList1" runat="server" style="width:50%;text-align:center;" forecolor="White" BackColor="#2E3842"> 
<asp:ListItem>یزد</asp:ListItem> 
             <asp:ListItem>aaa</asp:ListItem> 
             <asp:ListItem>bbb</asp:ListItem> 
</asp:DropDownList> 


如何设置文本中央?

+0

[Center align down down list text]可能重复(http://stackoverflow.com/questions/21665137/centre-align-drop-down-list-text) – MusicLovingIndianGirl

+1

[.net dropdownlist可能的重复对齐文本](http://stackoverflow.com/questions/761022/net-dropdownlist-align-text) –

回答

1

对齐文本中心在dropdown(选择列表)是不可能与css text-align。您可以在实际上使用text-indentpadding

select{text-indent:5px} 

<select style="padding-left: 5px;"> 
 
    <option>1</option> 
 
    <option>1</option> 
 
    <option>1</option> 
 
</select> 
 
<select style="text-indent: 25px;width: 80px;"> 
 
    <option>1</option> 
 
    <option>1</option> 
 
    <option>1</option> 
 
</select>

0

使用这一个:

<style> 
      select 
      { 
       width: 50%; 
       text-indent: 50%; 
       color: White; 
       background-color: #2E3842; 
      } 
     </style> 

     <asp:DropDownList ID="DropDownList1" runat="server" > 
      <asp:ListItem>یزد</asp:ListItem> 
      <asp:ListItem>aaa</asp:ListItem> 
      <asp:ListItem>bbb</asp:ListItem> 
     </asp:DropDownList> 
0

给这个如果保证金是不是选择的问题标签:

margin-left:50%; 
0

附加。

左对齐或右对齐

方向:ltr; // rtl

相关问题