0

我正在另一个表中创建一个表。我已将列划分为与外部表完全相同的比率。但是,这些列未与外部表列对齐。谁能告诉我我错过了什么?

<html>
	<div style="overflow:scroll;height:140px;width:100%;overflow:auto"  style="background-color:black">
		<table width="100%" style="padding:0; margin:0;"  cellpadding="0">
			<tr class="tbl_header"  cellpadding="0">
				<td width="3%">test1</td>
				<td width="7%">test2</td>
				<td width="3%">test3</td>                               
				<td width="12%">test4</td>
				<td width="7%">test5</td>
				<td width="10%"test6</td>                               
				<td width="7%">test7</td>  
			</tr>
			<tr  style="background-color:yellow">
				<td colspan="7" style="background-color:yellow">
					<div style="overflow:scroll;height:110px;width:100%;overflow:auto;border:none;background-color:green">
						<table width="100%" style="border:none;background-color:red" cellpadding="0">
							<tr class="even">
								<td width="3%">2</td>
								<td width="7%" class="tdAlign">Testing </td>
								<td width="3%" class="tdAlign">Testing </td>
								<td width="12%" class="tdAlign">Testing Testing Testing</td>                     
								<td width="7%">Testing_1</td>
								<td width="10%">Testing_2</td>  			
								<td width="7%">Testing_3</td>
							</tr>
						</table>
					</div>
				</td>
			</tr>
		</table>
	</div>
</html>

4

2 回答 2

0

<html>
	<div style="overflow:scroll;height:140px;width:100%;overflow:auto"  style="background-color:black">
		<table width="100%" style="padding:0; margin:0;"  cellpadding="0">
			<tr class="tbl_header"  cellpadding="0">
				<td width="3%">test1</td>
				<td width="7%">test2</td>
				<td width="3%">test3</td>                               
				<td width="12%">test4</td>
				<td width="7%">test5</td>
				<td width="10%">test6</td>                               
				<td width="7%">test7</td>  
			</tr>
			<tr  style="background-color:yellow">
				<td colspan="7" style="background-color:yellow">
					<div style="overflow:scroll;height:110px;width:100%;overflow:auto;border:none;background-color:green">
						<table width="100%" style="border:none;background-color:red" cellpadding="0">
							<tr class="even">
								<td width="3%">2</td>
								<td width="7%" class="tdAlign">Testing </td>
								<td width="3%" class="tdAlign">Testing </td>
								<td width="12%" class="tdAlign">Testing Testing Testing</td>                     
								<td width="7%">Testing_1</td>
								<td width="10%">Testing_2</td>  			
								<td width="7%">Testing_3</td>
							</tr>
						</table>
					</div>
				</td>
			</tr>
		</table>
	</div>
</html>

看起来您错过了<TD>( <td width="10%">test6</td>) 的结束标记。希望这可以帮助。让我知道

于 2018-01-18T09:12:39.900 回答
0

当我使用 chromes web kit 检查表格时。由于文本长度,我看到应该是 3% 的表格。你可以通过添加table-layout: fixed两个<table>元素来解决这个问题。

如果你想使用我建议使用的表头<th>见这里

于 2018-01-18T07:54:02.503 回答