html - 无论列数如何,表 colspan 跨越所有列

标签 html css asp.net html-table

我正在动态背后的 asp.net 代码中创建一个表,并且我想要一个只有 2 个单元格的页脚行。第一个应该跨越表 1 中的所有列。除了手动跟踪表中的列数之外,还有其他方法可以让我将 colspan 设置为 table-1 中所有列的 # 吗?

最好是 HTML 或 CSS 解决方案?

最佳答案

Colspan 不能用 CSS 来完成。它是结构性的而不是文体的,所以它是纯 HTML。

不,您不能将“除一个之外的所有”指定为 colspan。你能做的最好的是colspan="0" ,它将跨越列组中的其余列,但要利用 <colgroup>无论如何,顶部都需要知道列数并静态定义。

Tables在 HTML 规范中:

colspan = number [CN]

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/

相关文章:

html - iOS Safari 会用相同的内容自动填充每个字段吗?

javascript - fullpage.js,具有较大的部分并禁用某些部分的滚动

html - 溢出在此代码中不起作用

javascript - 我如何覆盖 jquery UI 中的类?

javascript - Windows Phone 8 图像比视口(viewport)宽

c# - 如何在 Asp.net 中隐藏浏览器的 .aspx 扩展名

html - Flex,使用 wrap 属性来阻塞

css - 在基础 CSS 中将全局 CSS 值应用于移动 View ?

asp.net - 如何使用 MVC Razor 设置类等 html 属性?

asp.net - Telerik RadGrid 溢出