HTML语言如何一次实现表格整列的对齐方式
2008-08-21 15:22
471 查看
HTML元素 - colGroup
定义
说明表格中一列或一组列的缺省属性。
Specifies property defaults for a column or group of columns in a table.
注释
嵌套的 COL 属性将覆盖 COLGROUP 属性。
使用 SPAN 属性可以指定 COLGROUP 定义的表格列数。该属性的缺省值为 1。
COL 元素可以出现在 COLGROUP 元素之外,这两个元素可用于类似的目的 。但是,你必须使用 COLGROUP 元素来决定表格内部分隔线(rules)应该处于的位置。见下面第一个例子。
若在 COLGROUP 中嵌套了 COL 元素则应该避免在 COLGROUP 中使用 SPAN 标签属性。这是因为属于嵌套的 COL 元素的 SPAN 标签属性将覆盖 COLGROUP 元素中的标签属性。这可能引起代码的混乱及可能并非所愿的结果。参见下面的第二个例子。
TABLE 对象及其关联元素有一个独立的表格对象模型,该模式使用不同于常规对象模型的方法 。要获得关于表格对象模型更多的信息,请参看如何动态生成表格。
此元素在 Internet Explorer 3.0 及以上版本的 HTML 中可用,在 Internet Explorer 4.0 及以上版本的脚本中可用。
此元素是块元素 。
此元素是块元素。COLGROUP 属性。 COLGROUP 元素之外,这两个元素可用于类似的目的。
此元素需要关闭标签 。
示例代码
下面的例子使用了 COLGROUP 元素指定表格中两组列的特征。
This example uses the COLGROUP element to assign specific characteristics to two groups of columns in a table.
<HTML>
<BODY>
<TABLE BORDER="2" RULES="groups">
<!-- RULES is set to "groups", which places internal dividing lines around
table columns defined by COLGROUP . -->
<COLGROUP SPAN="2" STYLE="color:red">
</COLGROUP>
<COLGROUP STYLE="color:blue">
</COLGROUP>
<TR>
<TD>This column is in the first group.</TD>
<TD>This column is in the first group.</TD >
<TD>This column is in the second group.</TD>
</TR>
<TR>
<TD>This column is in the first group.</TD>
<TD>This column is in the first group.</TD>
<TD>This column is in the second group.</TD>
</TR>
</TABLE>
</BODY>
</HTML>
若在 COLGROUP 中嵌套了 COL 元素,COL 元素的标签属性将覆盖 COLGROUP 元素的标签属性。下面的例子演示了这一点。
When COL elements are nested inside a COLGROUP element, the attributes of the COL elements override the attributes of the COLGROUP element. This is demonstrated in the following example.
<HTML>
<BODY>
<TABLE BORDER="2">
<COLGROUP SPAN="3" STYLE="color:green;background:black ">
<! -- Styling is applied to only the first two columns, instead of all
three, and the font color is red instead of green. This is consistant
with the attributes of the COL element. -->
<COL SPAN="2 " STYLE="color:red">
</COLGROUP>
<TR>
<TD>This column is in the first group.</TD>
<TD>This column is in the first group.</TD>
<TD>This column is in the second group .</TD>
</TR>
<TR>
<TD>This column is in the first group.</TD>
<TD>This column is in the first group.</TD>
<TD>This column is in the second group.</TD>
</TR>
</TABLE>
</BODY>
</HTML>
另见 COL 元素则应该避免在 COLGROUP 中使用?
另见
定义
说明表格中一列或一组列的缺省属性。
Specifies property defaults for a column or group of columns in a table.
注释
嵌套的 COL 属性将覆盖 COLGROUP 属性。
使用 SPAN 属性可以指定 COLGROUP 定义的表格列数。该属性的缺省值为 1。
COL 元素可以出现在 COLGROUP 元素之外,这两个元素可用于类似的目的 。但是,你必须使用 COLGROUP 元素来决定表格内部分隔线(rules)应该处于的位置。见下面第一个例子。
若在 COLGROUP 中嵌套了 COL 元素则应该避免在 COLGROUP 中使用 SPAN 标签属性。这是因为属于嵌套的 COL 元素的 SPAN 标签属性将覆盖 COLGROUP 元素中的标签属性。这可能引起代码的混乱及可能并非所愿的结果。参见下面的第二个例子。
TABLE 对象及其关联元素有一个独立的表格对象模型,该模式使用不同于常规对象模型的方法 。要获得关于表格对象模型更多的信息,请参看如何动态生成表格。
此元素在 Internet Explorer 3.0 及以上版本的 HTML 中可用,在 Internet Explorer 4.0 及以上版本的脚本中可用。
此元素是块元素 。
此元素是块元素。COLGROUP 属性。 COLGROUP 元素之外,这两个元素可用于类似的目的。
此元素需要关闭标签 。
示例代码
下面的例子使用了 COLGROUP 元素指定表格中两组列的特征。
This example uses the COLGROUP element to assign specific characteristics to two groups of columns in a table.
<HTML>
<BODY>
<TABLE BORDER="2" RULES="groups">
<!-- RULES is set to "groups", which places internal dividing lines around
table columns defined by COLGROUP . -->
<COLGROUP SPAN="2" STYLE="color:red">
</COLGROUP>
<COLGROUP STYLE="color:blue">
</COLGROUP>
<TR>
<TD>This column is in the first group.</TD>
<TD>This column is in the first group.</TD >
<TD>This column is in the second group.</TD>
</TR>
<TR>
<TD>This column is in the first group.</TD>
<TD>This column is in the first group.</TD>
<TD>This column is in the second group.</TD>
</TR>
</TABLE>
</BODY>
</HTML>
若在 COLGROUP 中嵌套了 COL 元素,COL 元素的标签属性将覆盖 COLGROUP 元素的标签属性。下面的例子演示了这一点。
When COL elements are nested inside a COLGROUP element, the attributes of the COL elements override the attributes of the COLGROUP element. This is demonstrated in the following example.
<HTML>
<BODY>
<TABLE BORDER="2">
<COLGROUP SPAN="3" STYLE="color:green;background:black ">
<! -- Styling is applied to only the first two columns, instead of all
three, and the font color is red instead of green. This is consistant
with the attributes of the COL element. -->
<COL SPAN="2 " STYLE="color:red">
</COLGROUP>
<TR>
<TD>This column is in the first group.</TD>
<TD>This column is in the first group.</TD>
<TD>This column is in the second group .</TD>
</TR>
<TR>
<TD>This column is in the first group.</TD>
<TD>This column is in the first group.</TD>
<TD>This column is in the second group.</TD>
</TR>
</TABLE>
</BODY>
</HTML>
另见 COL 元素则应该避免在 COLGROUP 中使用?
另见
相关文章推荐
- 不依赖第3方库,用30行JS代码如何实现电子表格
- 如何实现用DataGridView来做统计表格
- JS实现控制表格单元格垂直对齐的方法
- Flex中如何通过tabStyleName, tabWidth和textAlign样式,设置TabBar控件内文本对齐方式
- 如何实现虚拟主机与物理主机通过NAT的方式连通INTERNET
- 实现表格标题和内容列对齐的内嵌滚动方法
- 如何实现EditPlus、UE等工具的列选择,并且将选择的列复制到word中的表格
- Java多线程有哪几种实现方式? Java中的类如何保证线程安全? 请说明ThreadLocal的用法和适用场景
- 页面只能打开一次Cooike如何实现
- 『求助』如何在.NET实现表格嵌套
- 特殊需求:EF 6.x如何比较TimeSpan格式的字符串?EF Core实现方式是否和EF 6.x等同?
- 如何在JavaScript中实现私有属性的写类方式(一)
- 表格存储如何实现跨区域的容灾
- 使用Hibernate criteria进行分页查询时,如何实现一次查询取得总记录数和分页后结果集
- 如何实现表单一次上传多表数据并更新到数据库
- JavaScript是如何实现继承的(六种方式)
- 最简单的跨线程实现方式,不知使用如何,今天记下。明天试试!
- 如何通过非数字与字符的方式实现PHP WebShell详解
- 用最简单方式解释“依赖注入”及其如何实现
- Python四钟方式来实现“一次处理一个字符的方式处理字符串”