2015-12-21 23 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

相關問題