【问题标题】:Add a small space between tables在表格之间添加一个小空间
【发布时间】:2015-08-23 11:29:45
【问题描述】:

我想做的是在我的桌子之间添加一个小空间。当我使用<p><br> 时,空间太大了。有谁知道如何在表格之间留出很小的空间?

这是它的实际外观与我想要的外观:

我在 ASP:Panel 和中继器控件中执行此操作。

这是我的代码

<asp:Repeater ID="AcctRepeater" runat="server" onitemcommand="AcctRepeater_ItemCommand" OnItemDataBound="AcctRepeater_DataBinding">

  <HeaderTemplate>  
  </HeaderTemplate> 

  <ItemTemplate>
    <asp:Panel ID="Panel3" runat="server" BackColor="#ffffff" Height="125px" Style="margin-left: 1px" Width="800px" BorderColor="Black" BorderStyle="Solid" BorderWidth="1px">            
      <table width="790">
        <tr bgcolor="#007ACC" style="color:White">
          <td width="100">Account Number</td><td width="80">DOS</td><td width="30">Active</td><td width="240">Account Group</td><td width="180">Function</td>
        </tr>
        <tr>
          <td> 
            <asp:Label ID="lblAcctNum" runat="server" width="200px" Text='<%#Eval("UserName") %>'></asp:Label>
          </td>
          <td>
            <asp:Label ID="lblDOS" runat="server" Text='<%#Eval("UserDOB", "{0:d}") %>'></asp:Label>
          </td>
          <td> 
            <asp:Label ID="lblActive" runat="server" width="30px" Text='<%#Eval("UserTitle") %>'></asp:Label>
          </td>
          <td>
            <asp:Label ID="lblAcctGrp" runat="server" Text='<%#Eval("UserCity") %>'></asp:Label>
          </td>
          <td>
            <!--     <asp:LinkButton ID="LinkEdit" runat="server" CommandArgument='<%#Eval("UserImg") %>' CommandName="edit">Edit</asp:LinkButton>  -->
          </td>
        <tr>
        <tr>
          <td colspan = "2">
            <asp:Label ID="Label1" runat="server" Text='Added/Loaded By: '></asp:Label><asp:Label ID="lblLoadBy" runat="server" Text='<%#Eval("UserState") %>'></asp:Label>
          </td>
          <td  colspan ="3">
            <asp:Label ID="Label3" runat="server" Text='Added/Loaded On: '></asp:Label><asp:Label ID="lblLoadedOn" runat="server" Text='<%#Eval("UserGender") %>'></asp:Label>
          </td>
        </tr>   
      </table>
    </asp:Panel>
  </ItemTemplate>

  <SeparatorTemplate>  
  </SeparatorTemplate>

  <FooterTemplate>
  </FooterTemplate>

</asp:Repeater>

【问题讨论】:

  • 无法对此进行测试,但您尝试过 &lt;br&gt; 的地方 &lt;font size="4"&gt;&amp;nbsp&lt;/font&gt; 会起作用吗?
  • 4 有点大,但即使我将其降为 1,它仍然与


    标签的大小相同。

  • &lt;p style="line-height:50%" /&gt; ?

标签: css asp.net html html-table repeater


【解决方案1】:

您可以更改面板以包含下边距。所以改变:

<asp:Panel ID="Panel3" runat="server" BackColor="#ffffff" Height="125px" Style="margin-left: 1px" Width="800px" BorderColor="Black" BorderStyle="Solid" BorderWidth="1px">            

    <asp:Panel ID="Panel3" runat="server" BackColor="#ffffff" Height="125px" Style="margin-left: 1px;margin-bottom: 2px" Width="800px" BorderColor="Black" BorderStyle="Solid" BorderWidth="1px">            

【讨论】:

  • Frickin' A. 我如此接近。谢谢!
【解决方案2】:

设置table面板的bottom margin

【讨论】:

  • 我想保留桌子周围的边框,如问题所附图像所示。下边距不会这样做。
  • 所以设置在桌子周围的面板上