如何在表格宽度为100%的表格中添加页脚?

时间:2016-10-15 05:38:18

标签: html css html-table

我有一个简单的表格可以在 THIS 上看到,如果您在当前租借下查看表格,您会看到下表:

enter image description here

但实际上我的内容如下:

enter image description here

正如您所看到的,目前表格中缺少页脚,目前我对表格有以下标记:

<table class="current-rentals-table">
    <caption>
        <h4>Select Toys to Return</h4>
        <button class="btn-pink">return</button>
    </caption>
    <thead>
        <tr>
            <th></th>
            <th colspan="2">Toy Details</th>
            <th>Date Rented</th>
            <th>Return Date</th>
        </tr>
    </thead>
    <tbody>
        <tr>
            <td>
                <form action="">
                    <input type="checkbox" name="">
                </form>
            </td>
            <td>
                <img src="images/res/toy-cart/1.png" alt="toy image">
            </td>
            <td>
                <p>Praesent dapibus, neque id cursus faucibus,tortor neque egestas augue, eu vulputate magna eros eu erat. </p>
            </td>
            <td>Nov 12, 2015</td>
            <td>Dec 12, 2015</td>
        </tr>
        <tr>
            <td>
                <form action="">
                    <input type="checkbox" name="">
                </form>
            </td>
            <td>
                <img src="images/res/toy-cart/1.png" alt="toy image">
            </td>
            <td>
                <p>Praesent dapibus, neque id cursus faucibus,tortor neque egestas augue, eu vulputate magna eros eu erat. </p>
            </td>
            <td>Nov 12, 2015</td>
            <td>Dec 12, 2015</td>
        </tr>
        <!-- <tr>
             <td>
               <p>You have 0 credit left. <a href="">Increase your credit</a> to rent more toys or return toys you are currently renting.</p>
             </td>
           </tr> -->
    </tbody>
</table> 

如果我尝试使用以下代码向表中添加页脚:

<tr>
    <td>
         <p>You have 0 credit left. <a href="">Increase your credit</a> to rent more toys or return toys you are currently renting.</p>
    </td>
</tr>

它打破了桌子,所以我该如何将页脚添加到桌面?

1 个答案:

答案 0 :(得分:2)

使用tfoot标记:<tfoot>

...
</tbody>
<tfoot>
    <tr>
        <td colspan="5">
            <p>You have 0 credit left. <a href="">Increase your credit</a> to rent more toys or return toys you are currently renting.</p>
        </td>
    </tr>
</tfoot>