gpt4 book ai didi

HTML CSS 表格在底部而不是表格顶部显示行

转载 作者:行者123 更新时间:2023-12-02 04:55:11 25 4
gpt4 key购买 nike

我正在尝试完成动态构建的表格的格式化。在最后一页上,当表由于少于填充表所需的行数而变得稀疏时,这些行将显示在表空间的底部而不是顶部。我试图纠正这个失败。如何在顶部显示这些行?

这似乎无关紧要,但该表是由 will_paginate Ruby gem 构建的。我说没关系,因为当我查看 HTML 时,它只是一个表格。那里没有任何东西可以使这种情况发生。表格大小被格式化为显示 10 行。如果只有 3 个,它们将如您预期的那样列为 3 行。所以,我认为这只是一个 HTML/CSS 格式问题。

显示的表格: Show the table has it displays

SCSS:

.feeds {
list-style: none;
margin: 0;
text-align: left;
table-layout: fixed;
width: 700px;
height: 250px;
overflow: auto;
vertical-align: top;
li {
overflow: auto;
padding: 10px 0;
border-top: 1px solid $grayLighter;
&:last-child {
border-bottom: 1px solid $grayLighter;
}
}
table, thead, th, tr, tbody, tfoot {
vertical-align: top;
}
td {
vertical-align:top;
height: 1ex;
overflow-x: auto
}
}

HTML:

    <table class="feeds">
<tbody><tr>
<th id="url_cell"><a class="sortfield asc" href="/feeds?commit=Search&amp;direction=desc&amp;search=&amp;sort=feed_url&amp;utf8=%E2%9C%93">URL</a></th>
<th><a href="/feeds?commit=Search&amp;direction=asc&amp;search=&amp;sort=feed_etag&amp;utf8=%E2%9C%93">Etag</a></th>
<th><a href="/feeds?commit=Search&amp;direction=asc&amp;search=&amp;sort=feed_update&amp;utf8=%E2%9C%93">Update date</a></th>
</tr>
<tr>
<td id="url_cell"><a href="http://www.skalith.net/rss">http://www.skalith.net/rss</a></td>
<td id="etag_cell">RZWAFDMVHPXHWECK</td>
<td id="update_cell">August 5, 2013</td>
</tr>
<tr>
<td id="url_cell"><a href="http://www.viva.name/rss">http://www.viva.name/rss</a></td>
<td id="etag_cell">KFIEQYAUWMUHUJNY</td>
<td id="update_cell">August 5, 2013</td>
</tr>
</tbody></table>

最佳答案

标题行垂直填充空间(这是它应该做的,因为你的 table-layout 。如果你用 <thead> 包裹它然后只用 <tbody> 包裹表格的主体它将对齐它正确。但是,因为您有 table-layout: fixedheight: 250px ,剩余的行将增长以弥补差异。

参见:http://codepen.io/chrisrockwell/pen/gGmFq

如果表中没有完整的行集,是否可以向表中添加一个类?这样您就可以删除高度声明。

其他选项:

  1. 我猜您需要设置高度,但如果没有,您可以将其删除。

  2. 将表格包裹在 <div> 中并将你的高度和溢出分配给 div:

<div class="wrap">
<table class="feeds"></table>
</div>
.wrap {
height: 250px;
overflow: auto;
}
table {
/* just remove the height and overflow */
}

这是选项 2 的示例:http://codepen.io/chrisrockwell/pen/wpyfI

关于HTML CSS 表格在底部而不是表格顶部显示行,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18116931/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com