【问题标题】:MediaWIki table (infobox) goes to bottom-right of the pageMediaWIki 表(信息框)位于页面的右下角
【发布时间】:2015-01-13 03:47:07
【问题描述】:

我正在尝试将信息框添加到我的 MediaWiki 站点上的页面。

我的 common.css 中有这段代码:

.infobox { 
   border:1px solid #aaaaaa;
   background-color:#f9f9f9;
   padding:5px;
   font-size: 95%;
   border-collapse: collapse;
   margin-left: 20px;
}  

我在 Template:Infobox 中有这段代码

<table class="infobox" align="right" bgcolor="#E1E1E1" style="width:20em; font-size:90%; text-align:left; border: 1px green solid;">
<caption style="text-align:center; font-size:140%;"><i><b>{{{name}}}</b></i></caption>
<tr>
<td colspan="2" style="text-align:center;" bgcolor="#E1E1E1">{{{image}}}</td>
</tr>
<tr>
<td colspan="2" bgcolor="#E1E1E1" style="text-align:center;">{{{imagecaption}}}</td>
<tr>
<th>Author</th>
<td>{{{author}}}</td>
</tr>
<tr>
<th>Publisher</th>
<td>{{{publisher}}}</td>
</tr>
<tr>
<th>Publication date</th>
<td>{{{publication}}}</td>
</tr>
<tr>
<th>Illustrator</th>
<td>{{{illustrator}}}</td>
</tr>
<tr>
<th>Genre</th>
<td>{{{genre}}}</td>
</tr>
<tr>
<th>Pages</th>
<td>{{{pages}}}</td>
</tr>
<tr>
<th>ISBN</th>
<td>{{{isbn}}}</td>
</tr>

最后,这是我插入 MediaWiki 页面的代码:

{{Infobox
| name = The Hitchhiker's Guide to the Galaxy
| image = [[Image:Hhgttg.jpg|150px]]
| image_caption = Movie Poster
| author = Douglas Adams
| country = United Kingdom
| language = English
| series = The Hitchhiker's Guide to the Galaxy
| genre = Science Fiction
| publisher = Pan Books
| release_date = 1979
| media_type = Paperback and hardcover
| pages = 180
| isbn = ISBN 0-330-25864-8
| followed_by = The Restaurant at the End of the Universe
}}

我遇到的问题是信息框在我的 MediaWiki 页面的右下角对齐。我宁愿让它出现在右上角,就像在维基百科的这个页面中一样:http://en.wikipedia.org/wiki/Bill_Gates

我可以在我的代码中添加什么来实现这一点?

【问题讨论】:

  • ...什么?我不确定如何让信息框浮动到页面的 bottom 右上角。 (嗯,至少需要一些非常重要的脚本。)只是为了检查一下,您确实在页面的开头插入了信息框代码,对吗?
  • 是的,在一开始。您可以在这里查看页面:owpedia.com/wiki/Tracer

标签: mediawiki infobox


【解决方案1】:

哇,这很奇怪,但我想我已经找到了原因:

您忘记关闭模板内的&lt;table&gt;

因此,当模板在页面的开头展开时,页面的所有其余内容最终都会被放置在未关闭的 HTML 表格中。但是,由于您确实记得关闭 &lt;td&gt;&lt;tr&gt; 标记,因此它会包含在它们之外。

解析页面后,MediaWiki 在其上运行HTML Tidy。当 Tidy 看到您未关闭的表时,它会对它做两件事:

  • 它将缺少的&lt;/table&gt;标签添加到页面末尾。

  • 它看到表格内有一些内容,但在表格单元格之外,应该没有内容。它将该内容从表格中拉出,并将其放在表格之前。

最终结果是,未关闭表格之后的页面上的所有内容最终都会在最终整理好的 HTML 中向上移动到它之前。确实很奇怪。

可以说,HTML Tidy 应该更聪明地处理这种情况:如果它在最后一个表格单元格之后看到一个带有非表格标记的未关闭表格,它应该在那里关闭表格,而不是假设以下内容内容也是表格的一部分。可能值得将此作为对 Tidy 的错误/功能请求进行报告。也就是说,模板中未关闭或格式不正确的 HTML 标记还有很多其他方式可能会弄乱您的页面,因此修复这一特定情况可能不会对整体方案产生太大影响。

在您问之前,是的,在 MediaWiki 模板中拥有无与伦比的 HTML 的能力被认为是一项功能,因为它可以让您执行以下操作:

{{begin quote}}
This is some text wrapped in a fancy quote box by the surrounding templates.
{{end quote}}

无论如何,解决这个特殊问题很简单:只需将缺少的&lt;/table&gt; 添加到您的模板中即可。

【讨论】:

  • 谢谢。我在模板末尾添加了 ,现在它在页面顶部正确对齐。
  • 哇! @Ilmari Karonen 你救了我!我遇到了一个完全不同的情况,如此复杂以至于我什至懒得描述它(复合查询和嵌套在子模板中的语义内部对象),结果表会神奇地出现在页面的底部。当然,&lt;/table&gt; 不见了。非常感谢!!!
猜你喜欢
  • 2014-02-23
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2021-02-13
  • 1970-01-01
  • 2022-01-20
  • 2016-09-20
  • 2011-05-20
相关资源
最近更新 更多