CSS 使用“显示:表格单元格”有没有办法获得“colspan”功能?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/15829377/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-29 22:20:01  来源:igfitidea点击:

Using "display: table-cell" is there a way of getting the "colspan" functionality?

css

提问by fadedbee

Using display: table-cellis there a way of getting the colspanfunctionality, which is available when using real table cells?

使用display: table-cell是否有获取colspan功能的方法,该功能在使用真实表格单元格时可用?

In particular I need some "cells" to span multiple columns.

特别是我需要一些“单元格”来跨越多列。

Real tables are not a possibility as I am using a form per rowlayout, which won't validate as a real table.

真正的表格是不可能的,因为我使用的是每行布局的表格,它不会作为真正的表格进行验证。

回答by harishannam

No you cannot add colspan or rowspan to display:table-cell. It is one of the limitations in table-cell feature!

不,您不能将 colspan 或 rowspan 添加到 display:table-cell。这是表格单元格功能的限制之一!

You can check the limitations in this reference link

您可以查看此参考链接中的限制

http://www.onenaught.com/posts/201/use-css-displaytable-for-layout

http://www.onenaught.com/posts/201/use-css-displaytable-for-layout

If you want to bring the COLSPAN feature into table-cell, then you have to use table-row-group and table-caption feature as follows

如果要将 COLSPAN 功能带入 table-cell,则必须使用 table-row-group 和 table-caption 功能,如下所示

display: table-caption

and

table-row-group;

Check this fiddle link : http://jsfiddle.net/ZQQY4/

检查这个小提琴链接:http: //jsfiddle.net/ZQQY4/