user3671271 user3671271 - 7 months ago 12
HTML Question

Why my asp.net drop down list text align not set to center?

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?

Answer

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>

Comments