Extension:TemplateStyles/zh

TemplateStyles扩展引入了一个标签用于指定Wiki页面应该加载的一个样式表. 将此标签放入模板中可使该模板加载自定义的样式，而无需将样式放入.

关于编辑者如何在Wiki上使用该扩展，参见.

用法
首先需要创建一个CSS页面. 默认设置下，Template名字空间下任何标题以".css"结尾且没有语法错误的子页面都将创建为“已过滤的CSS”.

采用此模式的名字空间可用 调整，或者对任何页面使用. 然后，在模板的维基文本中添加并且来加载该样式.

采用“已过滤的CSS”内容模型保存的CSS必须满足严格的有效性要求：无效CSS、无法识别的规则以及不支持的属性/属性值无法保存. 如果仍以某些方式保存了无效的CSS，当CSS输出到浏览器时，存在问题的部分将被移除.

标签上的 属性的值是页面标题，默认视作Template名字空间. 例如，将加载“Template:Example/styles.css”页面. 如果该页面不存在或者不是“已过滤CSS”内容模型，则该操作失败.

可以使用可选参数 将样式限定在页面的特定范围内，例如将加载的样式限制于主解析内容中的任何元素上. 参数可使用任何CSS简单选择器序列. 此功能是为允许比对模板的线上与沙盒版本而设计.

已过滤CSS的使用与模板的嵌入引用（transclusion）一样被追踪，并如嵌入引用一样显示于.

注意事项
This should largely prevent redefining fonts used elsewhere in the document. Other classes on the  or   elements may be targeted in the same manner.
 * 模板样式所加入的样式被限制于 ，以免篡改主解析内容以外的用户界面.
 * 如要使模板样式生效于例如w:MediaWiki:Protectedpagetext，需将消息内容纳入于.
 * 样式应针对特定的CSS类（class）编写，并且生成使用这些类的元素的任何内容都应包含样式本身，而不要依赖其他模板来完成此目的.
 * 模板所包含的样式目前可能影响该模板所生成内容之外的页面内容，但未来或许会移除这种能力，因此不应对此有所依赖.
 * 模板所含样式影响了模板外的内容时，编辑特定章节且内容不含该模板时不会看到模板样式被应用. 举例来说，如果某个信息框上含有影响整个页面所有表格的样式，当编辑某个不含该信息框的章节时，预览章节不能在表格上看到这些样式.
 * 模板样式允许少数几个非标准化的CSS属性. 请求支持额外的属性应在Phabricator中的css-sanitizer与TemplateStyles项目中提交.
 * Requests should include links to standards-track documents (e.g. on w3.org) describing the syntax of the properties being requested, and an analysis of current browser support for the properties (e.g. a link to a caniuse.com page about the properties).
 * Vendor-prefixed properties (e.g. anything starting with,  , or  ) are likely to be declined if they're not needed for modern browsers.
 * rules must use a  prefixed with "TemplateStyles".
 * To target styles based on skins, use a selector such as ; specification of the   element is required and must be followed by a descendant combinator (i.e. the space).

Other dependencies
should be configured to use no tidying or RemexHtml. If used with any of the Raggett drivers, a tag in the middle of a paragraph (including in an inline template) will cause tidy to break the paragraph at that point. The other drivers have not been tested for this issue.

Potential errors
If you experience an error when importing pages from another wiki, for example, it may help to enable in your   to determine if you are experiencing any of the errors below.


 * This error may come up when attempting to import a wiki CSS page or when changing the content model of a page to "santized-css". There is, as of April 16, 2020, an open bug in the extension distributor which requires  to be run in the extension subdirectory even when the extension is not installed from Git. See Topic:Ukv6pdo96a8qfur2 for details.
 * Some people get this error on a wiki when importing pages. This extension provides that content model. Install TemplateStyles to fix your import.
 * Some people get this error on a wiki when importing pages. This extension provides that content model. Install TemplateStyles to fix your import.
 * Some people get this error on a wiki when importing pages. This extension provides that content model. Install TemplateStyles to fix your import.