0

How can you text align center in asp.net 4.0 ListBox element. I tried cssclass but not working. Thank you.

Furkan Gözükara
  • 22,964
  • 77
  • 205
  • 342

1 Answers1

0

This works for me:

<style type="text/css">
    .listbox-centered
    {
        width:400px;
        text-align:center;
    }
</style>

...

<asp:ListBox ID="listBox1" runat="server" CssClass="listbox-centered">
    <asp:ListItem Text="Item 1" Value="0"></asp:ListItem>
    <asp:ListItem Text="Item 2" Value="1"></asp:ListItem>
</asp:ListBox>
jdavies
  • 12,784
  • 3
  • 33
  • 33
  • doesn't work at ie. I also noticied that working in firefox and chrome. – Furkan Gözükara Sep 26 '11 at 19:34
  • Doesn't look like it is possible using CSS. Other questions exist on SO regarding the matter: [how to make sure select option text align in the center in IE?](http://stackoverflow.com/questions/1911111/how-to-make-sure-select-option-text-align-in-the-center-in-ie). – jdavies Sep 26 '11 at 19:47