Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/xml/15.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Asp.net 图像按钮未对准中心_Asp.net - Fatal编程技术网

Asp.net 图像按钮未对准中心

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(

给定GridView列的以下标记,为什么我的图像按钮显示为左对齐

<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;}

是的,你说得对-我更新了答案。您必须设置按钮和包含块的样式。