MediaWIki表(信息框)位于页面的右下角

时间:2014-11-16 00:03:07

标签: mediawiki infobox

我正在尝试将信息框添加到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

我可以将哪些内容添加到我的代码中以实现此目的?

1 个答案:

答案 0 :(得分:2)

哇,这是一个奇怪的,但我想我已经设法找出原因:

您忘记关闭模板中的<table>

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

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

  • 它将缺少的</table>标记添加到页面末尾。

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

最终结果是,在未关闭的表之后的页面上的所有内容最终都会在最终整理的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}}

无论如何,对此特定问题的修复很简单:只需将缺少的</table>添加到您的模板中。