我在 webForm 应用程序的下拉列表中居中项目(选项)时遇到问题。
这是一个带有 ddl 的表:
<table class="grid">
<tr>
<td class="gridPagerCell">
<asp:LinkButton ID="lbFirstPage" runat="server" Text="<<" OnCommand="onPage_Command" CommandName="PAGING" CommandArgument="<<" />
</td>
<td class="gridPagerCell">
<asp:LinkButton ID="lbPreviosPage" runat="server" Text="<" OnCommand="onPage_Command" CommandName="PAGING" CommandArgument="<" />
</td>
<td class="gridPagerCell">
<asp:DropDownList id="ddlSelectedPage" runat="server" CssClass="gridPagerDropDownList" AutoPostBack="True" OnSelectedIndexChanged="ddlSelectedPage_SelectedIndexChanged" />
</td>
<td class="gridPagerCell">
<asp:LinkButton ID="lbNextPage" runat="server" Text=">" OnCommand="onPage_Command" CommandName="PAGING" CommandArgument=">" />
</td>
<td class="gridPagerCell">
<asp:LinkButton ID="lbLastPage" runat="server" Text=">>" OnCommand="onPage_Command" CommandName="PAGING" CommandArgument=">>" />
</td>
<td style="width:100%; text-align:right;">
<asp:Literal ID="ltTotalCount" runat="server" />
</td>
</tr>
</table>
在我绑定下拉列表后面的代码中:
if (!this.IsPostBack)
{
this.ddlSelectedPage.Items.Clear();
for (int i = 0; i <= Helper.GetCountOfGridPages(this.TotalRecords, this.GridPageSize) - 1; i++)
{
var item = new ListItem((i + 1).ToString(), (i + 1).ToString());
this.ddlSelectedPage.Items.Add(item);
}
}
这是一个 CSS 样式:
.gridPagerDropDownList
{
width:125px;
text-align:center;
left: auto;
}
.grid
{
width:100%;
color: #000000;
}
.gridPagerCell
{
margin-right: 5px;
margin-left: 5px;
padding-right: 5px;
padding-left: 5px;
}
问题是,在 FF 中,我在 dll 中心的下拉列表中看到文本,在 IE 和 Chrome 中,文本向左对齐,但我希望它在所有浏览器的中心对齐...
有什么解决办法吗?