Extension:CSS/zh

CSS擴展允許將CSS樣式表載入到特定文章中. CSS樣式表可以是另一個文檔，也可以是直接在解析器函數中定義的規則.

用法
例如，如果你有一個名為「MyStyles.css」的CSS樣式表，它們是用於共筆頁「MyFancyUserPage」的樣式，你可以為後者添加以下解析器函數語法：

再者，如果「MyStyles.css」是位於/wiki/skins目錄之下的檔案，那麼路徑應該也被寫進去，如下所示. 請注意，檔案路徑必須是帶有文件根目錄斜杠的絕對路徑，以將其與檔名區分開來.

或者，CSS規則可以直接包含在解析器函數(inline)中，如下例所示：

Configuration
Optionally, you can set the base URL for external files.

Use as a PageCSS replacement
There is a prior Extension:PageCSS (now archived) which used &lt;css> and &lt;/css> tags instead of the #css: parser function. This extension can do most of what those extensions provide, but the syntax is incompatible. One way to avoid breaking existing pages which still use the old &lt;css> tags is to use both this Extension:CSS and Extension:NewPageCSS on the same wiki.

An alternate solution (if you want to use only this extension, but have existing content which expects Extension:PageCSS) is to save this stub function as a PHP file and include it from your LocalSettings.php to remap &lt;css> to #css:

At this point, the prior PageCSS (or NewPageCSS) extensions may be removed from your configuration; &lt;css> now goes to #css: and (if you have this CSS extension already up and running) will behave the way any of the other CSS extensions always have.

Problems with changing the color or background of a specific page
Using the parser function to use the CSS from another page does not work to change the color or background of the page, however, using the parser function on a single page by itself does allow the background to be changed. To overcome this problem, it is possible to load the CSS through transclusion, which does not cause the problem of failing to load the change to the page background.

Bugs
See talk page.