我知道的唯一方法,除了创建一个带有浮动<div>
s 的虚拟表之外,是使用Labeled Section Transclusion (或者如果你有Extension:DynamicPageList,它的等效{{#dpl}}
函数)。您使用标签或标题分别标记“列模板”的每个单元格,然后创建一个框架表,通过从列模板中嵌入来填充每一行。结构看起来像这样:<section/>
{|class="wikitable sortable" style="font-size:85%"
|+ table name
! Title 1
! Title 2
! Title 3
|- valign="top
| {{#lst:col1|row1}}
| {{#lst:col2|row1}}
| {{#lst:col3|row1}}
|- valign="top
| {{#lst:col1|row2}}
| {{#lst:col2|row2}}
| {{#lst:col3|row2}}
|- valign="top
| {{#lst:col1|row3}}
| {{#lst:col2|row3}}
| {{#lst:col3|row3}}
...
|}
这种解决方案缺乏像丢弃行那样丢弃列的简单性,但遗憾的是,HTML 并不是为创建真正的基于列的表而设计的。但是,使用这种布局,至少每列中的所有信息都存储在同一页面上,您可以更轻松地对其进行编辑({{col1}}
、{{col2}}
等),如果您正在记录文本信息,那么您还可以将每列读取为可能很方便的不同页面。
如果您打算经常这样做,您可以通过创建一个填充每一行的模板来进一步简化此操作,因此您只需要指定行号,如下所示:(假设您的列始终作为文章的子页面放置他们会出现)
template:col-based table row
{{!}}- valign="top"
{{!}} {{#lst: {{PAGENAME}}/col1 | row{{{1|}}} }}
{{!}} {{#lst: {{PAGENAME}}/col2 | row{{{1|}}} }}
{{!}} {{#lst: {{PAGENAME}}/col3 | row{{{1|}}} }}
然后在标题下你只需要列出:
{{col-based table row|1}}
{{col-based table row|2}}
{{col-based table row|3}}
...
Now, if you want to automatically-generate these rows until you exhaust the template (or in other words, have the table determine how many rows to create without you manually setting them up), that I don't think I can help you with. Perhaps you can do something clever with the DPL extension's table generation function, or install an extension that will allow you to create loops, but I think you'll probably be stuck creating each row manually as described above.
As a final note, because this is content and not formatting I'd advise that you put the column pages in the mainspace rather than the template namespace. In fact, this is the sort of thing that subpages are great for.