2

在创建 mediawiki 皮肤时,我将如何将目录放在主页面内容区域之外的侧边栏上?

4

2 回答 2

1

首先确保没有打印出 TOC,请参阅https://www.mediawiki.org/wiki/Extension:NoTOC

然后我建议你将Parser::formatHeadings的相关部分复制到你的皮肤上,在你想要的地方创建一个 TOC。

但是,除非您真的非常需要它出现在所有用户的文章之外,否则我认为使用 Javascript 将 #toc 移动到您想要的位置会容易得多。

于 2013-11-01T06:52:46.303 回答
0

如果您希望目录位于一边但无论用户的滚动位置如何都保持可用,您可以使用 CSS 属性position: fixed(以下适用于具有默认 Vector 皮肤的 MW 1.24.4 以及内置 MonoBook、Modern 和 Cologne Blue 皮肤):

#toc {
    position: fixed;
    right: 0;
    top: 7em; /* 5em is height of header, 6em brings just under */
    /* bottom: 5em; /* 5em puts us above the footer; not bad but too low when TOC is collapsed */

    z-index: 10000; /* Ensure we float above the header, etc. */

    /* Add opacity (translucency) */
    background-color: rgb(249, 249, 249);
    background-color: rgba(249, 249, 249, 0.9); /* Higher opacity (last arg) means less transparency */
}
/* Ensure the TOC height doesn't take over the screen; percentages may be higher than view port, so we use pixels */
#toc > ul {
    max-height: 350px;
    overflow: auto; 
}
于 2016-03-29T16:49:58.427 回答