rowspan
と とcolspan
をcol
説明できる人はいますcolgroup
か? そして、これらの W3C は有効で意味的に正しいのでしょうか? これらはどのような状況で役立ちますか?
13045 次
3 に答える
16
コルスパン
<table border="1">
<tr>
<th colspan="2">people are...</th>
</tr>
<tr>
<td>monkeys</td>
<td>donkeys</td>
</tr>
</table>
行スパン
<table border="1">
<tr>
<th rowspan="2">monkeys are...</th>
<td>... real monkeys</td>
</tr>
<tr>
<td>... 'unreal' monkeys (people...)</td>
</tr>
</table>
w3c
ご覧のとおり、これはテーブル セルを接続するためのものです。これは必要な場合もあるため、有効です (RegDwights リンクで詳細情報が得られます...)。
列/列グループ
colgroup
そして、テーブルのすべての行に属性を設定するために使用されます (したがって、すべての行の最初に ( )col
を記述する必要はありません)。width="80"
td
tr
<table border="1">
<colgroup>
<col width="80">
<col width="100">
<col width="320">
</colgroup>
<tr>
<td>first line, first column</td>
<td>first line, second column</td>
<td>first line, third column</td>
</tr>
<!-- more table-lines... -->
</table>
列をグループ化することもできます。たとえば、1 列目と 2 列目with
が 80 になり、3 列目が 320 になるはずです。
<table border="1">
<colgroup width="80" span="2"></colgroup>
<colgroup width="320" span="1"></colgroup>
<tr>
<td>first line, first column</td>
<td>first line, second column</td>
<td>first line, third column</td>
</tr>
<!-- more table-lines... -->
</table>
于 2010-03-10T11:44:08.967 に答える
1
rowspan
とcolspan
は、デザイナーがセルを「マージ」できるようにする属性です。これは、Excel の同じコマンドとよく似ています (たとえば)。
col
cssをcolgroup
列の個々のセルに適用するのではなく、デザイナーが css を垂直列に適用できるようにします。これらがないと、html テーブルは行ベースであるため、このタスクは非常に困難になります。
これらの 4 つすべてが有効です。
于 2010-03-10T11:36:40.100 に答える