Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

Tags:

html

asp.net

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?

like image 248
user3671271 Avatar asked Jan 29 '26 17:01

user3671271


1 Answers

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>
like image 85
Tushar Avatar answered Jan 31 '26 06:01

Tushar



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!