我正在动态背后的 asp.net 代码中创建一个表,并且我想要一个只有 2 个单元格的页脚行。第一个应该跨越表 1 中的所有列。除了手动跟踪表中的列数之外,还有其他方法可以让我将 colspan 设置为 table-1 中所有列的 # 吗?
最好是 HTML 或 CSS 解决方案?
最佳答案
Colspan 不能用 CSS 来完成。它是结构性的而不是文体的,所以它是纯 HTML。
不,您不能将“除一个之外的所有”指定为 colspan。你能做的最好的是colspan="0"
,它将跨越列组中的其余列,但要利用 <colgroup>
无论如何,顶部都需要知道列数并静态定义。
见 Tables在 HTML 规范中:
This attribute specifies the number of columns spanned by the current cell. The default value of this attribute is one ("1"). The value zero ("0") means that the cell spans all columns from the current column to the last column of the column group (
COLGROUP
) in which the cell is defined.
但基本上这只是在街上踢 jar 头,我不知道浏览器支持是什么样的,所以它不一定会给你买任何东西。
您在生成 HTML 或使用 Javascript 时需要知道列数。
关于html - 无论列数如何,表 colspan 跨越所有列,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2388576/