gpt4 book ai didi

html - 表格 Thead 与 TD Cells 不匹配并且不符合表格大小

转载 作者:太空宇宙 更新时间:2023-11-03 18:49:44 25 4
gpt4 key购买 nike

如何修改下面的代码,使 Table THead 与 TD 相匹配,并遵守表格的大小(宽度)?现在发生的情况是表格标题超出了 div 的大小,并且表格水平地横跨整个页面。

<!DOCTYPE html>
<html>
<head>
<link rel="stylesheet" href="http://code.jquery.com/ui/1.10.1/themes/base/jquery-ui.css" />
<script src="http://code.jquery.com/jquery-1.9.1.js"></script>
<script src="http://code.jquery.com/ui/1.10.1/jquery-ui.js"></script>

<style type="text/css">

/*------------------------------------------------------------------
Table Style
------------------------------------------------------------------ */
table a:link {
color: #666;
font-weight: bold;
text-decoration:none;
}
table a:visited {
color: #999999;
font-weight:bold;
text-decoration:none;
}
table a:active,
table a:hover {
color: #bd5a35;
text-decoration:underline;
}
table {
font-family:Arial, Helvetica, sans-serif;
color:#666;
font-size:12px;
background:#eaebec;
border-radius:3px;
border-collapse:collapse; border-spacing: 0;
box-shadow: 0 1px 2px #d1d1d1;
border-left: 1px solid #ccc;
border-right: 1px solid #ccc;
table-layout: fixed;


}
table th {
border-bottom:1px solid #ccc;
border-left: 1px solid #ccc;
background: #ededed;
}
table tr {
text-align: center;
}
table td {
border-bottom:1px solid #ccc;
border-left: 1px solid #ccc;
background: #fafafa;
text-align: left;
}
table tr:hover td {
background: #f2f2f2;
}
table th, table td {
height: 20px;
width: 200px;
}
#container {
width : 98.7%;
height: 300px;
overflow-x: scroll;
overflow-y: scroll;
}
table tr td:first-child, table tr th:first-child {
border-left: 0;
}

table thead {
_position: fixed;
_position: relative;
_position: absolute;

}

TABLE THEAD TR TH {
top:expression(this.offsetParent.scrollTop);
border-top:1px solid #ccc;
_position:relative;
_position: absolute;
_position: fixed;
}

table tr:first-child td {
border-top: 0;
}
</style>

</head>

<body>

<div id="container">

<table id="data">

<!-- Table Header -->
<thead>
<tr>
<th>File Number</th>
<th>&nbsp;</th>
<th>&nbsp;</th>
<th>Firstname</th>
<th>Lastname</th>
<th>Progress</th>
<th>Vital Task</th>
</tr>
</thead>
<!-- Table Header -->

<!-- Table Body -->
<tbody>

<tr>
<td>ABC-123-123456</td>
<td>&nbsp;</td>
<td>&nbsp;</td>
<td>&nbsp;</td>
<td>&nbsp;</td>
<td>100%</td>
<td>Yes</td>
</tr><!-- Table Row -->

<tr>
<td>ABC-123-123456</td>
<td>&nbsp;</td>
<td>&nbsp;</td>
<td>&nbsp;</td>
<td>&nbsp;</td>
<td>100%</td>
<td>Yes</td>
</tr><!-- Darker Table Row -->

<tr>
<td>ABC-123-123456</td>
<td>&nbsp;</td>
<td>&nbsp;</td>
<td>&nbsp;</td>
<td>&nbsp;</td>
<td>20%</td>
<td>No</td>
</tr>

<tr>
<td>ABC-123-123456</td>
<td>&nbsp;</td>
<td>&nbsp;</td>
<td>&nbsp;</td>
<td>&nbsp;</td>
<td>80%</td>
<td>No</td>
</tr>

<tr>
<td>ABC-123-123456</td>
<td>&nbsp;</td>
<td>&nbsp;</td>
<td>&nbsp;</td>
<td>&nbsp;</td>
<td>&nbsp;</td>
<td>&nbsp;</td>
</tr>

<tr>
<td>ABC-123-123456</td>
<td>&nbsp;</td>
<td>&nbsp;</td>
<td>&nbsp;</td>
<td>&nbsp;</td>
<td>&nbsp;</td>
<td>&nbsp;</td>
</tr>

<tr>
<td>ABC-123-123456</td>
<td>&nbsp;</td>
<td>&nbsp;</td>
<td>&nbsp;</td>
<td>&nbsp;</td>
<td>&nbsp;</td>
<td>&nbsp;</td>
</tr>

<tr>
<td>ABC-123-123456</td>
<td>&nbsp;</td>
<td>&nbsp;</td>
<td>&nbsp;</td>
<td>&nbsp;</td>
<td>&nbsp;</td>
<td>&nbsp;</td>
</tr>

<tr>
<td>ABC-123-123456</td>
<td>&nbsp;</td>
<td>&nbsp;</td>
<td>&nbsp;</td>
<td>&nbsp;</td>
<td>100%</td>
<td>Yes</td>
</tr>

<tr>
<td>ABC-123-123456</td>
<td>&nbsp;</td>
<td>&nbsp;</td>
<td>&nbsp;</td>
<td>&nbsp;</td>
<td>23%</td>
<td>yes</td>
</tr>

<tr>
<td>ABC-123-123456</td>
<td>&nbsp;</td>
<td>&nbsp;</td>
<td>&nbsp;</td>
<td>&nbsp;</td>
<td>80%</td>
<td>No</td>
</tr>

<tr>
<td><a href="#yep-iit-doesnt-exist">Hyperlink Example</a></td>
<td>&nbsp;</td>
<td>&nbsp;</td>
<td>&nbsp;</td>
<td>&nbsp;</td>
<td>80%</td>
<td><a href="#inexistent-id">Another</a></td>
</tr>

</tbody>
<!-- Table Body -->

</table>
<script>
$(function() {
$( "#data tr th" ).resizable({
handles: 'e'
});
});
</script>
</div>

</body>
</html>

预计到达时间

最佳答案

将容器的 CSS 编码修复为:

#container {
width : 98.7%;
height: 300px;
overflow-x: scroll;
overflow-y: scroll;

position: fixed;
}

问题已通过 IE7 解决。

关于html - 表格 Thead 与 TD Cells 不匹配并且不符合表格大小,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15343876/

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