.net dropdownlist align text

2019-02-26 12:52发布

I am trying to align the text in my .net dropdownlist to the right. Using CssClass I am able to align text to the right in Firefox.

IE doesn't not align text to the right it aligns to the left. I have read that IE 6 doesn't support this.

  1. Is this true?

I am using IE7 but most of my users will be in IE 6 so, both need to work.

<asp:DropDownList ID="ddlNomination" Width="250px" CssClass="ddlnomination"
    runat="server" DataSourceID="Azoa" DataTextField="nomination_type" 
    DataValueField="nomination_type">
    <asp:ListItem> </asp:ListItem>
</asp:DropDownList>

css

.ddlnomination
{
   text-align:right;
}

2条回答
Rolldiameter
2楼-- · 2019-02-26 13:46

Setting it (text-align="right") on the Select or Option elements in IE6, IE7 & IE8 (even in standards mode) does not appear to work.

Some quick stats after testing.

Browser    |  Result
 Firefox 3     Passes
 Opera 9.5     Passes
 IE 6          Fails
 IE 7          Fails
 IE 8          Fails
 Safari 3      Fails
 Safari 4      Fails
 Chrome        Fails on the Option element, Passes on the Select element
查看更多
beautiful°
3楼-- · 2019-02-26 13:55

It's sadly true Dedrick...

If right-aligning it in IE6 is really important, maybe you could add blank spaces to fill the left of the elements and make them measure the same. A real pain anyway... -1 reputation points for IE6 in this one!

查看更多
登录 后发表回答