Asp.net 图像按钮未对准中心
给定GridView列的以下标记,为什么我的图像按钮显示为左对齐Asp.net 图像按钮未对准中心,asp.net,Asp.net,给定GridView列的以下标记,为什么我的图像按钮显示为左对齐 <ItemStyle HorizontalAlign="Center" Width="55px" /> <ItemTemplate> <asp:ImageButton ID="removeButton" runat="server" ImageUrl="~/Images/Icons/x-m.png" CommandArgument='<%# Eval(
<ItemStyle HorizontalAlign="Center" Width="55px" />
<ItemTemplate>
<asp:ImageButton ID="removeButton" runat="server"
ImageUrl="~/Images/Icons/x-m.png"
CommandArgument='<%# Eval("ResourceId") %>'
AlternateText="Remove Button"
onclick="removeButton_Click" />
</ItemTemplate>
你会使用css吗?使用以下css进行样式设置可能会更幸运 假设x-m.png的宽度是25px
.X { width: 55px; }
.Y { display: block; margin: 0 auto; width: 25px; }
<ItemStyle cssClass="X" />
<ItemTemplate>
<asp:ImageButton ID="removeButton" runat="server"
ImageUrl="~/Images/Icons/x-m.png"
CommandArgument='<%# Eval("ResourceId") %>'
AlternateText="Remove Button"
onclick="removeButton_Click"
cssClass="Y"/>
</ItemTemplate>
.X{宽度:55px;}
.Y{显示:块;边距:0自动;宽度:25px;}
是的,你说得对-我更新了答案。您必须设置按钮和包含块的样式。