<colgroup>的学习

本文演示如何在HTML中使用colgroup元素设置表格列宽,并通过改变colgroup中的宽度比例,观察相应td元素宽度的变化。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

写一个简单的<colgroup>的测试
<html>
<head></head>
<body>
	<table width="100%" border="1">
	  <colgroup   width=20></colgroup>
	  <colgroup  width=10></colgroup>
	   <colgroup   width=30></colgroup>
	  <tr>
		<th>ISBN</th>
		<th>Title</th>
		<th>Price</th>
	  </tr>
	  <tr>
		<td>3476896</td>
		<td>My first HTML</td>
		<td>$53</td>
	  </tr>
	</table>
</body>
</html>

改变<colgroup>中的宽度比例,则相应的td的宽度成对应比例变化
<tr> <!-- <th width="25"><input type="checkbox" group="ids" class="checkboxCtrl"></th> <th width="35" orderField="id" <if condition="$_REQUEST._order eq 'id'">class="{$_REQUEST._sort}"</if>>{$Think.lang.id}</th> <th width="50" orderField="merix_pn" <if condition="$_REQUEST._order eq 'merix_pn'">class="{$_REQUEST._sort}"</if>>816#</th> <th width="40" orderField="part_number" <if condition="$_REQUEST._order eq 'part_number'">class="{$_REQUEST._sort}"</if>>Tooling_no</th> <th orderField="tooling_type" <if condition="$_REQUEST._order eq 'tooling_type'">class="{$_REQUEST._sort}"</if>>工具类型</th> <th orderField="film_type" <if condition="$_REQUEST._order eq 'film_type'">class="{$_REQUEST._sort}"</if>>工具</th> <th orderField="remark" <if condition="$_REQUEST._order eq 'remark'">class="{$_REQUEST._sort}"</if>>备注信息</th> <th orderField="tooling_status" <if condition="$_REQUEST._order eq 'tool_status'">class="{$_REQUEST._sort}"</if>>工具状态</th> <th orderField="recorder" <if condition="$_REQUEST._order eq 'recorder'">class="{$_REQUEST._sort}"</if>>操作者</th> <th orderField="record_time" <if condition="$_REQUEST._order eq 'record_time'">class="{$_REQUEST._sort}"</if>>时间</th> <th orderField="repo_man" <if condition="$_REQUEST._order eq 'repo_man'">class="{$_REQUEST._sort}"</if>>工具回收</th> <th orderField="recycle_time" <if condition="$_REQUEST._order eq 'recycle_time'">class="{$_REQUEST._sort}"</if>>工具回收时间</th> <th orderField="reviewed_by" <if condition="$_REQUEST._order eq 'reviewed_by'">class="{$_REQUEST._sort}"</if>>工具回收(确认)</th> <th orderField="Audit_time" <if condition="$_REQUEST._order eq 'Audit_time'">class="{$_REQUEST._sort}"</if>>工具回收(确认)时间</th> <th orderField="recycle_remark" <if condition="$_REQUEST._order eq 'recycle_remark'">class="{$_REQUEST._sort}"</if>>回收备注</th> --> <th width="2%" ><input type="checkbox" group="ids" class="checkboxCtrl"></th> <th width="3%" orderField="id" <if condition="$_REQUEST._order eq 'id'">class="{$_REQUEST._sort}"</if>>{$Think.lang.id}</th> <th width="5%" orderField="merix_pn" <if condition="$_REQUEST._order eq 'merix_pn'">class="{$_REQUEST._sort}"</if>>816#</th> <th width="5%" orderField="part_number" <if condition="$_REQUEST._order eq 'part_number'">class="{$_REQUEST._sort}"</if>>Tooling_no</th> <th width="4%" orderField="tooling_type" <if condition="$_REQUEST._order eq 'tooling_type'">class="{$_REQUEST._sort}"</if>>工具类型</th> <th width="5%"orderField="film_type" <if condition="$_REQUEST._order eq 'film_type'">class="{$_REQUEST._sort}"</if>>工具</th> <th width="20%"orderField="remark" <if condition="$_REQUEST._order eq 'remark'">class="{$_REQUEST._sort}"</if>>备注信息</th> <th width="6%" orderField="tooling_status" <if condition="$_REQUEST._order eq 'tool_status'">class="{$_REQUEST._sort}"</if>>工具状态</th> <th width="4%" orderField="recorder" <if condition="$_REQUEST._order eq 'recorder'">class="{$_REQUEST._sort}"</if>>操作者</th> <th width="10%" orderField="record_time" <if condition="$_REQUEST._order eq 'record_time'">class="{$_REQUEST._sort}"</if>>时间</th> <th width="4%" orderField="repo_man" <if condition="$_REQUEST._order eq 'repo_man'">class="{$_REQUEST._sort}"</if>>工具回收</th> <th width="10%" orderField="recycle_time" <if condition="$_REQUEST._order eq 'recycle_time'">class="{$_REQUEST._sort}"</if>>工具回收时间</th> <th width="4%" orderField="reviewed_by" <if condition="$_REQUEST._order eq 'reviewed_by'">class="{$_REQUEST._sort}"</if>>工具回收(确认)</th> <th width="10%" orderField="Audit_time" <if condition="$_REQUEST._order eq 'Audit_time'">class="{$_REQUEST._sort}"</if>>工具回收(确认)时间</th> <th width="10%"orderField="recycle_remark" <if condition="$_REQUEST._order eq 'recycle_remark'">class="{$_REQUEST._sort}"</if>>回收备注</th> </tr> 为什么以上的film_type 字段,在页面第一次进去时,宽度会随着内容而变长,但只要换页或者点击后,宽度又变回了设置的5%
最新发布
08-14
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值