1

我有以下设计:

在此处输入图像描述

代码:

   <table width="70%" align="center" class ="TableBorder">
            <tr>
                <td colspan="2" class="Heading" align="center">
                    Add Client
                </td>
            </tr>

           <tr>
                <td class="NormalText" align="right">
                    Client Name:
                </td>
                <td align="left">
                    <asp:TextBox ID="txtClientName" runat="server" CssClass="ThinTextBox"></asp:TextBox>
                    <asp:Label ID="lblAgentName0" runat="server" ForeColor="#FF3300" Text="*"></asp:Label>
                </td>
            </tr>
            <tr>
                <td class="NormalText" width="40%" align="right">
                    Client Login Email ID:
                </td>
                <td align="left">
                    <asp:TextBox ID="txtClientID" runat="server" CssClass="ThinTextBox"></asp:TextBox>
                    <asp:Label ID="lblAgentName1" runat="server" ForeColor="#FF3300" Text="*"></asp:Label>
                </td>
            </tr>

            <tr>
                <td class="NormalText" align="right">
                    Client Password:
                </td>
                <td align="left">
                    <asp:TextBox ID="txtClientPwd" runat="server" CssClass="ThinTextBox"></asp:TextBox>
                    <asp:Label ID="lblAgentName2" runat="server" ForeColor="#FF3300" Text="*"></asp:Label>
                </td>
            </tr>
            <tr>
                <td align="right" class="NormalText">
                    Contact No.:</td>
                <td align="left">
                    <asp:TextBox ID="txtContactNo" runat="server" CssClass="ThinTextBox"></asp:TextBox>
                    <asp:Label ID="lblAgentName3" runat="server" ForeColor="#FF3300" Text="*"></asp:Label>
                </td>
            </tr>
            <tr>
                <td align="right" class="NormalText" valign="top"  >
                    Address:</td>
                <td align="left">
                    <asp:TextBox ID="txtAddress" runat="server" CssClass="ThinTextBox" 
                        Height="100px" TextMode="MultiLine" Width="200px"></asp:TextBox>
                    <asp:Label ID="lblAgentName4" runat="server" ForeColor="#FF3300" Text="*"></asp:Label>
                </td>
            </tr>
            <tr>
                <td align="right" class="NormalText" width="30%">
                    &nbsp;
                </td>
                <td align="left">
                    <asp:Button ID="btnSave" runat="server" CssClass="ButtonColor" Text="Save" />
                    &nbsp;<asp:Button ID="btnCancel" runat="server" CssClass="ButtonColor" 
                        Text="Cancel" />
                </td>
            </tr>
        </table>

我只是想删除地址文本框的标记区域和“*”标签之间的间距。

我试图将属性作为 valign="top" 给标签,但它不接受它。

请帮我。

4

3 回答 3

2

尝试这个

添加样式=“垂直对齐:顶部;” 去标记

<asp:Label ID="lblAgentName4" runat="server" ForeColor="#FF3300" Text="*" style="vertical-align:top;"></asp:Label>
于 2013-08-06T10:06:42.327 回答
1

试试这个,

<table width="70%" align="center" class="TableBorder">
            <tr>
                <td colspan="3" class="Heading" align="center">
                    Add Client
                </td>
            </tr>
            <tr>
                <td class="NormalText" align="right">
                    Client Name:
                </td>
                <td align="left" colspan="2">
                    <asp:TextBox ID="txtClientName" runat="server" CssClass="ThinTextBox"></asp:TextBox>
                    <asp:Label ID="lblAgentName0" runat="server" ForeColor="#FF3300" Text="*"></asp:Label>
                </td>
            </tr>
            <tr>
                <td class="NormalText" width="40%" align="right">
                    Client Login Email ID:
                </td>
                <td align="left" colspan="2">
                    <asp:TextBox ID="txtClientID" runat="server" CssClass="ThinTextBox"></asp:TextBox>
                    <asp:Label ID="lblAgentName1" runat="server" ForeColor="#FF3300" Text="*"></asp:Label>
                </td>
            </tr>
            <tr>
                <td class="NormalText" align="right">
                    Client Password:
                </td>
                <td align="left" colspan="2">
                    <asp:TextBox ID="txtClientPwd" runat="server" CssClass="ThinTextBox"></asp:TextBox>
                    <asp:Label ID="lblAgentName2" runat="server" ForeColor="#FF3300" Text="*"></asp:Label>
                </td>
            </tr>
            <tr>
                <td align="right" class="NormalText">
                    Contact No.:
                </td>
                <td align="left" colspan="2">
                    <asp:TextBox ID="txtContactNo" runat="server" CssClass="ThinTextBox"></asp:TextBox>
                    <asp:Label ID="lblAgentName3" runat="server" ForeColor="#FF3300" Text="*"></asp:Label>
                </td>
            </tr>
            <tr>
                <td align="right" class="NormalText" valign="top">
                    Address:
                </td>
                <td align="left" class="style1" valign="top">
                    <asp:TextBox ID="txtAddress" runat="server" CssClass="ThinTextBox" Height="100px"
                        TextMode="MultiLine" Width="200px"></asp:TextBox>
                </td>
                <td align="left" valign="top">
                    <asp:Label ID="lblAgentName4" runat="server" ForeColor="#FF3300" Text="*"></asp:Label>
                </td>
            </tr>
            <tr>
                <td align="right" class="NormalText" width="30%">                    
                </td>
                <td align="left" colspan="2">
                    <asp:Button ID="btnSave" runat="server" CssClass="ButtonColor" Text="Save" />
                    &nbsp;<asp:Button ID="btnCancel" runat="server" CssClass="ButtonColor" Text="Cancel" />
                </td>
            </tr>
        </table>
于 2013-08-06T09:57:37.177 回答
1

您必须使用文本垂直对齐:文本顶部;在你的 td 的 css 中是这样的:

<td align="left" style="vertical-align: text-top;">
   <asp:TextBox ID="txtAddress" runat="server" CssClass="ThinTextBox" 
               Height="100px" TextMode="MultiLine" Width="200px"></asp:TextBox>
   <asp:Label ID="lblAgentName4" runat="server" ForeColor="#FF3300" Text="*"></asp:Label>
</td>

因为您的 asp 将您的 Label 控件呈现为 html span元素,而 span 需要 text-top 样式/

于 2013-08-06T10:06:44.197 回答