【问题标题】:Table - Increasing the space between header and first row表格 - 增加标题和第一行之间的空间
【发布时间】:2011-09-05 11:14:09
【问题描述】:

我想增加表头行和表中第一行之间的空间。我该怎么做?

我有以下:

<asp:Repeater ID="myRepeater" runat="server" >
   <HeaderTemplate>
        <table style="width:100%;" border="0" cellpadding="0" cellspacing="0">
            <thead>
                <tr align="left">
                        <th style="width:15%">
                            Column 1  
                        </th>
                        <th style="width:15%">
                            Column 2
                        </th>
                        <th style="width:15%">
                            Column 3
                        </th>                            
                     </tr>
                </thead>
        </HeaderTemplate>
        <ItemTemplate>
                <tbody style="padding-top: 50px;">
                    <tr>
                        <td></td>
                        <td></td>
                        <td></td>
                   </tr>                        
                </tbody>
        </ItemTemplate>
        <SeparatorTemplate>
            <tr style="padding-bottom: 30px;">
                <td colspan="7" style="padding-bottom: 20px; padding-top: 20px;">
                    <hr style="width:100%" /></td>
            </tr>
        </SeparatorTemplate>
        <FooterTemplate>
            </table>
        </FooterTemplate>
    </asp:Repeater> 

如您所见,我添加了&lt;style="padding-top: 50px;"&gt; 到表格主体,但这不起作用。

【问题讨论】:

    标签: html asp.net html-table repeater


    【解决方案1】:

    最简单的方法是在&lt;th&gt; 元素的底部添加填充

    <th style="width:15% padding-bottom: 50px">
         Column 1  
    </th>
    <th style="width:15% padding-bottom: 50px">
         Column 2
    </th>
    <th style="width:15%; padding-bottom: 50px">
         Column 3
    </th>
    

    注意:这有利于测试目的,但这确实应该在样式表中完成,而不是直接在 html 中。

    th {
        padding-bottom: 50px;
    }
    

    【讨论】:

      【解决方案2】:

      不确定,但也许:

      thead{padding-bottom:2em;}
      

      会给你想要的结果。

      【讨论】:

      • 你不能对thead元素应用填充,给它一个测试,什么都不会发生,就像你不能填充trtbody
      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2023-04-10
      • 2017-09-07
      • 1970-01-01
      • 2023-04-02
      • 1970-01-01
      • 2016-05-08
      相关资源
      最近更新 更多