Extension:CSS/zh

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

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

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

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

配置
你可以为扩展文件设置基本URL，可选.

作为页面CSS替代使用
There is a prior (now archived) which used  and  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 tags is to use both this Extension:CSS and  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.

改变特定页面颜色或背景的问题
使用解析器函数使用另一个页面的CSS不能够用于改变页面的颜色或背景，然而，使用解析器函数在单个页面可以允许页面的背景改变. 若要解决这个问题，通过内嵌来加载CSS，就不会导致无法改变页面背景的问题. 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.

漏洞
见讨论页.

参见

 * - a similar extension which sanitized the CSS and stores it on separate pages.
 * - a similar extension which sanitized the CSS and stores it on separate pages.