如何在自定义媒体维基皮肤的主页内容区域之外插入目录



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

首先确保目录未打印出来,请参阅 https://www.mediawiki.org/wiki/Extension:NoTOC

然后,我建议您将Parser::formatHeadings的相关部分复制到您的皮肤上,以在您想要的位置创建一个目录。

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

如果您希望目录位于一侧,但无论用户的滚动位置如何都保持可用,则可以使用 CSS 属性position: fixed(以下内容适用于带有默认矢量皮肤的 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; 
}

最新更新