Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/255.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/jquery/80.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 滚动时,表格标题固定在顶部_Php_Jquery_Css_Html Table - Fatal编程技术网

Php 滚动时,表格标题固定在顶部

Php 滚动时,表格标题固定在顶部,php,jquery,css,html-table,Php,Jquery,Css,Html Table,我正在尝试设计一个HTML表格,在向下滚动时标题将固定在页面顶部,但它不起作用。下面是我的html代码 <table align="center"> <?php $select = "SELECT * FROM register where r_bid='".$_SESSION["id"]."' order by `name` "; $result = mysql_query($select) or die(mysql_error()); $res

我正在尝试设计一个HTML表格,在向下滚动时标题将固定在页面顶部,但它不起作用。下面是我的html代码

<table align="center">
<?php               
$select = "SELECT * FROM register where r_bid='".$_SESSION["id"]."' order by `name` ";
$result = mysql_query($select) or die(mysql_error());
$res = mysql_query("select * from regi_balic where b_id='".$_SESSION["id"]."'");
$row1=mysql_fetch_array($res);
$i=1;
echo'<thead><tr align="center">
<th width=3%><font size=3><strong>No.</strong></font></th>
<th width=10%><font size=3><strong>IC</strong></font></th>
<th width=12%><font size=3><strong>Name</strong></font></th>
<th width=12%><font size=3><strong>Reference</strong></font></th>
<th width=2%><font size=3><strong>Age</strong></font></th>
<th width=12%><font size=3><strong>Occupatin</strong></font></th>
<th width=5%><font size=3><strong>Mobile No</strong></font></th>
<th width=2%><font size=3><strong>Delete</strong></font></th>
</tr></thead>';
while($row = mysql_fetch_array($result))
{   
echo '<tbody><tr>
<td width="3%" align="center" ><font size=3>'.$i.'</font></td>
<td width="10%"><font size=3>'.$row1['name'].'</font></td>
<td width="12%" align="left" ><font size=3>
<a href="edit_detail.phpid='.$row["r_id"].'
&cand_id='.$_SESSION["id"].'&email='.$row["email"].'">'.$row['name'].'</a></font></td>
<td width="12%" align="center" ><font size=3>'.$row['reference'].'</font></td>
<td width="2%" align="right" style="padding-right:8px" >
<fontsize=3>'.$row['age'].'</font></td>
<td width="12%" align="right" style="padding-right:8px"><font 
size=3>'.$row['occupation'].'</font></td>
<td width="5%" align="right"><font size=3>'.$row['mob_no'].'</font></td>
<td width="2%"><a href="process_del_client.php?id='.$row['r_id'].'" onClick="return  
ConfirmSubmit(\'Are You sure ?\')"><img src = "images/delete.png"></a></td>
</tr></tbody>';
$i++;
}
echo '</table></div></center>';                 
?>
</div>
像这样的


使thead-css位置:fixed/absolute.add-style位置:fixed用于表头。我已经这样做了,但是thead正在覆盖第一行。thead{position:fixed;width:78%;}我已经将其添加到了dstill中,面临同样的问题,现在thead会粘在页面的顶部,如果我试图将css样式设置为top:100px;到thead,然后它再次重写您的问题要求的第一行“一个HTML表格,在向下滚动时标题将固定在页面顶部。”但现在您不希望表格标题“固定在页面顶部”?您希望表格的标题在哪里?我的意思是表格标题应该固定在它的位置,行应该向下滚动
.list {
height: 409px;
width: 80%;
overflow: scroll;
}
table {
  height: 1000px; /* To force existence of a scrollbar. */
  background: yellow; /* To aid seeing boundaries. */
}

th {
  position: fixed; /* Fixes its position to the window. */
  top: 0; /* Sets that fixed position to stick to the top of the window. */
  width: 100%; /* Fills the width of the window; made it easier to see in your markup. */
  background: pink; /* To aid seeing boundaries. */
}