Colspan 所有列 [英] Colspan all columns
问题描述
如何指定一个 td
标签应该跨越所有列(当表格中的确切列数可变/难以确定何时呈现 HTML 时)?w3schools 提到您可以使用 colspan="0"
,但是它并没有确切说明哪些浏览器支持该值(IE 6 在我们的支持列表中).
How can I specify a td
tag should span all columns (when the exact amount of columns in the table will be variable/difficult to determine when the HTML is being rendered)? w3schools mentions you can use colspan="0"
, but it doesn't say exactly what browsers support that value (IE 6 is in our list to support).
似乎将 colspan
设置为大于您可能拥有的理论列数的值将起作用,但如果您设置了 table-layout
,它将不起作用到 fixed
.对 colspan
使用大量自动布局有什么缺点吗?有没有更正确的方法?
It appears that setting colspan
to a value greater than the theoretical amount of columns you may have will work, but it will not work if you have table-layout
set to fixed
. Are there any disadvantages to using an automatic layout with a large number for colspan
? Is there a more correct way of doing this?
推荐答案
我有 IE 7.0、Firefox 3.0 和 Chrome 1.0
I have IE 7.0, Firefox 3.0 and Chrome 1.0
TD 中的 colspan="0" 属性不跨越上述任何浏览器中的所有 TD.
The colspan="0" attribute in a TD is NOT spanning across all TDs in any of the above browsers.
也许不建议将其作为适当的标记实践,但是如果您提供一个colspan 值比可能的总数更高的值.其他行中的列数,则 TD 将跨越所有列.
Maybe not recommended as proper markup practice, but if you give a higher colspan value than the total possible no. of columns in other rows, then the TD would span all the columns.
当表格布局 CSS 属性设置为固定时,这不起作用.
再说一次,这不是完美的解决方案,但当 table-layout CSS 属性为automatic时,这似乎适用于上述 3 个浏览器版本.希望这会有所帮助.
Once again, this is not the perfect solution but seems to work in the above mentioned 3 browser versions when the table-layout CSS property is automatic. Hope this helps.
这篇关于Colspan 所有列的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!