3

I use drop down in my web application ,but when i run that i see text alignment not set to center,my drop down list html code is this:

<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>


how can i set text to center?

user3671271
  • 551
  • 2
  • 8
  • 21

5 Answers5

1

Aligning text center in a dropdown (select list) is not possible with css text-align. You can in fact use text-indent or padding

like

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>
Tushar Gupta
  • 15,504
  • 1
  • 29
  • 47
0

Use this one:

 <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>
Nazir Ullah
  • 610
  • 5
  • 13
0

Give this if margin is not an issue for select tag:

margin-left:50%;
Cijo V J
  • 261
  • 1
  • 3
  • 14
0

Additional.

for align left or right

direction:ltr; //rtl

ayed abboushi
  • 71
  • 2
  • 4
0

The solution is margin:0px auto;