ASP.NET-文本对齐

ASP.NET-文本对齐,asp.net,text,html-table,center,Asp.net,Text,Html Table,Center,我有一个对齐问题: 我需要的是“删除原因”文本垂直对齐,以红色“X”为中心。我尝试使用带有CSS和style=verticalalign:middle的div标记;但它迫使“删除原因”隐藏在“X”下面 如何使文本垂直居中?非常感谢您的帮助 PS-以下是代码: <tr> <td class="style7" valign="middle"> <asp:UpdatePanel ID="UpdatePanel1" runat="server"

我有一个对齐问题:

我需要的是“删除原因”文本垂直对齐,以红色“X”为中心。我尝试使用带有CSS和style=verticalalign:middle的div标记;但它迫使“删除原因”隐藏在“X”下面

如何使文本垂直居中?非常感谢您的帮助

PS-以下是代码:

 <tr>
     <td class="style7" valign="middle">
         <asp:UpdatePanel ID="UpdatePanel1" runat="server">
            <ContentTemplate>
              <asp:ImageButton ID="ibClearReasons" runat="server" Height="30px" Width="30px" ImageUrl="~/Images/DeleteRed.png" AlternateText="Delete" />Delete Reasons
            </ContentTemplate>
         </asp:UpdatePanel>
     </td>

     <td class="style6">
         <asp:LinkButton ID="SendToBatch" runat="server" BackColor="#20548E" BorderColor="#20548E" BorderStyle="Solid" Font-Names="Tahoma" Font-Size="Small" Font-Underline="False" 
                                 ForeColor="White" Height="16px" Width="85px" EnableViewState="True" CausesValidation="False"><center>Send To Batch</center></asp:LinkButton>&#160;&#160;&#160;&#160;
     </td>
 </tr>
必须在元素上设置垂直对齐属性:

如果img高度很小,它很有可能仍然会向外看。对于类似的问题,您需要将“delete reasons”包装在标记中,并为其提供padding top属性。

试试这个

<td class="style7" valign="middle">
     <asp:UpdatePanel ID="UpdatePanel1" runat="server">
        <ContentTemplate>
            <div style="float:left;margin:0px 4px;width:30px;">
                <asp:ImageButton ID="ibClearReasons" 
                                 runat="server" 
                                 Height="30px" 
                                 Width="30px" 
                                 ImageUrl="~/Images/DeleteRed.png" 
                                 AlternateText="Delete" />
            </div>
            <div style="float:left;height:30px;padding:6px 0px;width:100px;">
                 Delete Reasons
            </div>
            <div style="clear:both"></div>
        </ContentTemplate>
     </asp:UpdatePanel>
 </td>

您可能需要在第二个div上使用填充和/或宽度,以使其刚好正确。如果这样做有效,您可以简单地将内联样式移动到具有类名div.className HTH的css文件中,但如何将垂直对齐嵌入asp图像按钮中?属性不是属性,因此它不会在Tag的style属性中呈现。我只是在下面的应用程序中尝试了我的代码,如果您感兴趣,它工作得很好。嗯
<td class="style7" valign="middle">
     <asp:UpdatePanel ID="UpdatePanel1" runat="server">
        <ContentTemplate>
            <div style="float:left;margin:0px 4px;width:30px;">
                <asp:ImageButton ID="ibClearReasons" 
                                 runat="server" 
                                 Height="30px" 
                                 Width="30px" 
                                 ImageUrl="~/Images/DeleteRed.png" 
                                 AlternateText="Delete" />
            </div>
            <div style="float:left;height:30px;padding:6px 0px;width:100px;">
                 Delete Reasons
            </div>
            <div style="clear:both"></div>
        </ContentTemplate>
     </asp:UpdatePanel>
 </td>