<div id="temptable">
<table>
<tbody>
<tr style="background-color:#000000;color:white;">
<th style="float:left;">
<input type="checkbox" value="0" year="0" onchange="selectElement(this);">
</th>
<th style="width:25px;" colspan="2">YEAR</th>
<th>UNIT</th>
</tr>
</tbody>
<tbody>
<tr style="background-color: #006400;">
<th style="float:left;">
<input type="checkbox" value="0" year="2015" onchange="selectElement(this);">
</th>
<th colspan="2"><strong> 2015</strong>
</th>
<th onclick="dropdown(this);"><b>UNIT:>></b>
</th>
</tr>
<tr>
<td style="float:left;">
<input type="checkbox" value="11" year="2015">
</td>
<td style="width:25px;" colspan="2">1</td>
<td><a href="paper/aptitude.pdf" target="_blanck"><img src="image/download.png"></a>
</td>
</tr>
</tbody>
<tbody>
<tr style="background-color: #006400;">
<th style="float:left;">
<input type="checkbox" value="0" year="2014" onchange="selectElement(this);">
</th>
<th colspan="2"><strong> 2014</strong>
</th>
<th onclick="dropdown(this);"><b>UNIT:>></b>
</th>
</tr>
<tr style="display: none;">
<td style="float:left;">
<input type="checkbox" value="7" year="2014">
</td>
<td style="width:25px;" colspan="2">1</td>
<td><a href="paper/aptitude.pdf" target="_blanck"><img src="image/download.png"></a>
</td>
</tr>
</tbody>
<tbody>
<tr style="background-color: #006400;">
<th style="float:left;">
<input type="checkbox" value="0" year="2013" onchange="selectElement(this);">
</th>
<th colspan="2"><strong> 2013</strong>
</th>
<th onclick="dropdown(this);"><b>UNIT:>></b>
</th>
</tr>
<tr style="display: none;">
<td style="float:left;">
<input type="checkbox" value="6" year="2013">
</td>
<td style="width:25px;" colspan="2">1</td>
<td><a href="paper/aptitude.pdf" target="_blanck"><img src="image/download.png"></a>
</td>
</tr>
</tbody>
<tbody>
<tr style="background-color: #006400;">
<th style="float:left;">
<input type="checkbox" value="0" year="2011" onchange="selectElement(this);">
</th>
<th colspan="2"><strong> 2011</strong>
</th>
<th onclick="dropdown(this);"><b>UNIT:>></b>
</th>
</tr>
<tr style="display: none;">
<td style="float:left;">
<input type="checkbox" value="12" year="2011">
</td>
<td style="width:25px;" colspan="2">1</td>
<td><a href="paper/aptitude.pdf" target="_blanck"><img src="image/download.png"></a>
</td>
</tr>
<tr style="display: none;">
<td style="float:left;">
<input type="checkbox" value="14" year="2011">
</td>
<td style="width:25px;" colspan="2">1</td>
<td><a href="paper/aptitude.pdf" target="_blanck"><img src="image/download.png"></a>
</td>
</tr>
</tbody>
</table>
</div>
桌子的宽度是100%;我想要左边的复选框和年份显示,右边的单位显示;使用float
或text-align
无效。
答案 0 :(得分:0)
您应该首先修复表格格式 - 标记不是要包装每一行,而只是标题行下面的部分(应该用标记包装)。仅适用于表格的第一行(http://www.w3schools.com/tags/tag_tbody.asp)
<table>
<thead>
<tr>
<th>CHECKBOX</th>
<th>YEARS</th>
<th>UNITS</th>
</tr>
</thead>
<tbody>
<tr>
<td>checkbox</td>
<td>year</td>
<td>unit</td>
</tr>
<tr>
<td>checkbox</td>
<td>year</td>
<td>unit</td>
</tr>
<tr>
<td>checkbox</td>
<td>year</td>
<td>unit</td>
</tr>
</tbody>
</table>