html 中< col>标签和< colgroup>标签的区别

转载自https://www.ggbiji.com/html-col-colgroup.html

<col>标签是给表格中一个或多个列定义属性值,而<colgroup>标签是对表格中的列进行组合,从而实现对表格的格式化。<col>标签一般会放在<colgroup>标签中使用,对<colgroup>标签组合的列分别设置样式。<colgroup>标签也可以有样式属性,是对组合的列设置相同的样式,<colgroup>标签设置的样式会被<col>标签设置的样式覆盖。

格式:

<colgroup span="跨几列">
<col 属性1="属性值1" 属性2="属性值2"....../>
<col 属性1="属性值1" 属性2="属性值2"....../>
</colgroup>

实例:

<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>html 中< col>标签和< colgroup>标签的区别笔记_PHP笔记</title>
</head>
<body style="font-size:28px;">
<table width="450" border="1">
<colgroup style="background:red">
</colgroup>
<colgroup span="2" style="background:black">
<col style="background:yellow">
<col style="background:red">
</colgroup>
<tr><th>学号</th><th>姓名</th><th>成绩</th></tr>
<tr><td>01</td><td>张三</td><td>50</td></tr>
<tr><td>02</td><td>李四</td><td>90</td></tr>
</table>
</body>
</html>

运行结果:

转载于:https://www.cnblogs.com/youknowUL/p/11507361.html

  • 1
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
<!DOCTYPE html> <html> <head> <style> table { border-collapse: collapse; width: 100%; } td, th { border: 1.5px solid black; padding: 5px; } </style> </head> <body> <table> <colgroup> <col style="width: 5px;"> <col style="width: 5px;"> <col style="width: 5px;"> <col style="width: 5px;"> <col style="width: 5px;"> <col style="width: 5px;"> <col style="width: 5px;"> <col style="width: 50px;"> <col style="width: 1000px;"> <col style="width: 100px;"> <col style="width: 100px;"> <col style="width: 100px;"> <col style="width: 100px;"> <col style="width: 100px;"> <col style="width: 50px;"> </colgroup> <tr> <td contenteditable="true"><input type="text" oninput="filterTable(0)" placeholder="工艺膜层"></td> <td contenteditable="true"><input type="text" oninput="filterTable(1)" placeholder="AOI Step"></td> <td contenteditable="true"><input type="text" oninput="filterTable(2)" placeholder="不良类型"></td> <td contenteditable="true"><input type="text" oninput="filterTable(3)" placeholder="Layer(Code)"></td> <td contenteditable="true"><input type="text" oninput="filterTable(4)" placeholder="Type"></td> <td contenteditable="true"><input type="text" oninput="filterTable(5)" placeholder="Dpet"></td> <td contenteditable="true"><input type="text" oninput="filterTable(6)" placeholder="Subcode"></td> <td contenteditable="true">Code描述</td> <td contenteditable="true">Image1</td> <td contenteditable="true">Image2</td> <td contenteditable="true">Image3</td> <td contenteditable="true">Image4</td> <td contenteditable="true">Image5</td> <td contenteditable="true">Image6</td> <td contenteditable="true">判定细则</td> </tr> </thead> <tbody> <tr> <td contenteditable="true">ACT</td> <td contenteditable="true">Particle</td> <td contenteditable="true">ACT</td> <td contenteditable="true">Particle</td> <td contenteditable="true">ACT</td> <td contenteditable="true">Particle</td> <td contenteditable="true">ACT</td> <td contenteditable="true">Particle</td> <td> <input type="file" onchange="previewImage(this)" onclick="showPopup(this.src)"style="width: 100px; height: auto;" > </td> <td> <input type="file" onchange="previewImage(this)"onclick="showPopup(this.src)" style="width: 100px; height: auto;"> </td> <td> <input type="file" onchange="previewImage(this)" onclick="showPopup(this.src)"style="width: 100px; height: auto;"> </td> <td> <input type="file" onchange="previewImage(this)" onclick="showPopup(this.src)"style="width: 100px; height: auto;"> </td> <td> <input type="file" onchange="previewImage(this)" onclick="showPopup(this.src)"style="width: 100px; height: auto;"> </td> <td> <input type="file" onchange="previewImage(this)"onclick="showPopup(this.src)"style="width: 100px; height: auto;"> </td> <td contenteditable="true">Particle</td> </tr> </tbody> </table> </body> </html>这个代码内为什么无法调整列宽
最新发布
07-17

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值