【发布时间】:2014-05-27 22:55:32
【问题描述】:
我正在尝试使用滚动条来实现我的表格,该滚动条只会显示大约 10 个团队,直到它迫使您向下滚动。但是,我似乎无法正确编码。
我计划在几个不同的页面上实现可滚动表格,其中列标题的宽度会发生变化。我发现的所有示例都需要每列的固定宽度,有没有更好的方法来做到这一点?
** 我想保留固定的标题 **
这是我的 PHP 代码:
echo '<table align="center" cellspacing="3" cellpadding="3" width="80%" border="1">
<tr>
<th align="center">Team Name</th>
<th align="center">Wins</th>
<th align="center">Losses</th>
<th align="center">Winning %</th>
</tr><div id="scrll_tbl">';
$bg = '#eeeeee';
for($i = 0; $i < count($teams); $i++) {
$bg = ($bg == '#eeeeee' ? '#fffffff' : '#eeeeee');
$wnpctg = $teams[$i][1] / ($teams[$i][1] + $teams[$i][2]);
echo '<tr bgcolor="' .$bg. '">
<td align="center">' . $teams[$i][0] . '</td>
<td align="center">' . $teams[$i][1] . '</td>
<td align="center">' . $teams[$i][2] . '</td>
<td align="center">' . number_format($wnpctg,3) . '</td>
</tr>';
}
echo '</div></table>';
这是我的 CSS:
#scrll_tbl {
overflow: scroll;
height: 100px;
}
【问题讨论】:
-
当滚动到达页面末尾时,您是否尝试加载更多数据?
-
不,数据是在页面加载之前加载的
-
stackoverflow.com/questions/9707397/… 的可能副本我想你会在那里得到答案。
-
我做了,它把 div 放在我的桌子上方,而不是在里面
-
你能举个例子吗?
标签: php html css scroll html-table