Template:Fmbox/doc:修订间差异
删除的内容 添加的内容
创建 Template:Fmbox/doc 文档 |
小无编辑摘要 |
||
| (未显示1个用户的6个中间版本) | |||
第1行:
{{Mbox templates}}
{{
{{uses TemplateStyles|MediaWiki:Gadget-SiteCommon.css}}
本模板{{tl|fmbox}}為'''頁首與頁尾訊息框'''(footer and header message box)。
本模板可用于构建[[MediaWiki:Sp-contributions-footer-anon]]等系统消息的消息框,也可用于用户页的页首与页脚消息框,以及[[Help:编辑提示|编辑提示]]。
本模板与{{tl|ambox}}工作原理类似,大部分参数相同;主要区别在于本框宽度为 100%,且配色风格不同。
==
简易用法如下:
<pre>
{{fmbox | text = 範例文字。}}
</pre>
{{fmbox | text = 範例文字。}}
完整用法如下:
<pre>
{{fmbox
| type = editnotice
| image = [[File:Emblem-question-yellow.svg|40px]]
| style = border: 1px solid #f4c430;
| textstyle = color: red; font-weight: bold; font-style: italic;
| text = 訊息主體文字。
}}
</pre>
{{fmbox
| type = editnotice
| image = [[File:Emblem-question-yellow.svg|40px]]
| style = border: 1px solid #f4c430;
| textstyle = color: red; font-weight: bold; font-style: italic;
| text = 訊息主體文字。
}}
== 页首与页尾消息框类型 ==
以下示例使用了不同的<code>type</code>参数,但未指定<code>image</code>参数,因此会显示各类型的默认图片。
{{fmbox
| type = warning
| text = type=<u>warning</u> —— 警告通知,如 [[MediaWiki:Revision-info]] 与 [[MediaWiki:Protectedpagewarning]]。
}}
{{fmbox
| type = editnotice
| text = type=<u>editnotice</u> —— 透明背景,用于[[Help:编辑提示|编辑提示]]。
}}
{{fmbox
| type = system
| text = type=<u>system</u> —— 浅灰色系统消息背景(默认)。
}}
== 其他图片 ==
上方显示的默认图片大多用于测试与演示。多数情况下,更适合使用更具体的图片,或完全不使用图片。以下示例通过<code>image</code>参数指定了默认图片以外的图片。
{{fmbox
| image = [[File:User-info.svg|40px]]
| text = image = <nowiki>[[File:User-info.svg|40px]]</nowiki> <br> 此图片用于 [[MediaWiki:Sp-contributions-footer]]。
}}
== 特殊用法 ==
一些其他参数组合。
{{fmbox
| text = 未指定图片(默认)
}}
{{fmbox
| image = none
| text = '''image=none''' —— 不使用图片,<code>text</code>占满整个消息框区域。
}}
{{fmbox
| image = [[File:User-info.svg|40px]]
| imageright = [[File:Nuvola apps bookcase.svg|40px]]
| text = image = <nowiki>[[File:User-info.svg|40px]]</nowiki> <br> imageright = <nowiki>[[File:Nuvola apps bookcase.svg|40px]]</nowiki>
}}
== 参数 ==
全部参数列表:
<pre>
{{fmbox
| type = system / editnotice / warning
| image = none / [[File:Some image.svg|40px]]
| imageright = [[File:Some image.svg|40px]]
| id = CSS id
| class = CSS class names
| style = CSS values
| textstyle = CSS values
| text = 消息正文。
}}
</pre>
'''type'''
:若未指定<code>type</code>参数,模板默认使用 type=<u>system</u>,即浅灰色背景。
'''image'''
:'''未指定参数''' = 未指定<code>image</code>参数时,模板会根据<code>type</code>参数使用对应的默认图片。
:'''指定图片''' = 应使用常规 wiki 图片语法,例如:
::<code><nowiki>image = [[File:User-info.svg|40px]]</nowiki></code>
::宽度 40px–50px 通常比较合适(取决于图片宽高比);消息框可容纳任意尺寸的图片。
:'''none''' = 不使用图片。
'''imageright'''
:'''未指定参数''' = 未指定<code>imageright</code>参数时,右侧不显示图片。
:'''指定图片''' = 应使用常规 wiki 图片语法,例如:
::<code><nowiki>imageright = [[File:Nuvola apps bookcase.png|40px]]</nowiki></code>
::宽度 40px–50px 通常比较合适;消息框可容纳任意尺寸的图片。
:'''任意内容''' = 可在右侧显示任意其他对象。
'''id'''
:整个消息框的可选CSS id,不带引号 <code>" "</code>。主要用于标记消息框名称,便于 JavaScript 检测。例如 [[MediaWiki:Sp-contributions-footer]] 使用:
::<code>id = sp-contributions-footer</code>
'''class'''
:整个消息框的可选CSS类名,不带引号 <code>" "</code>。主要用于标记消息框名称,便于单独定制皮肤。例如 [[MediaWiki:Sp-contributions-footer]] 使用:
::<code>class = sp-contributions-footer</code>
'''style'''
:整个消息框的可选CSS样式,不带引号 <code>" "</code>,但需以分号 <code>;</code> 结尾。例如:
::<code>style = margin-top: 1em;</code>
'''textstyle'''
:文字单元格的可选CSS样式。例如:
::<code>textstyle = font-size: 90%; text-align: center;</code>
'''text'''
:消息正文。
== 技术细节 ==
本模板目前使用硬编码的样式与类名,未来将仅使用 CSS 类以便更换皮肤(目前可通过 "<code>!important</code>" 关键字覆盖样式)。
如需制作宽度小于 100% 的消息框,请''不要''使用本模板,改用{{tl|ombox}}。因为本框没有使其他消息框在宽度小于 100% 时于所有浏览器中获得正确框流布局的"1px 空图片单元格"代码。
若需在<code>text</code>参数中使用特殊字符,需如下转义:
<pre>
{{fmbox
| text = <div>
等号 = 与前后大括号 { } 可以正常使用。
但管道符 {{!}} 与两个相连的后大括号 <nowiki>}}</nowiki> 不能直接使用。
一起使用同样需要 nowiki 标记 <nowiki>|}}</nowiki>。
</div>
}}
</pre>
{{fmbox
| text = <div>
等号 = 与前后大括号 { } 可以正常使用。
但管道符 {{!}} 与两个相连的后大括号 <nowiki>}}</nowiki> 不能直接使用。
一起使用同样需要 nowiki 标记 <nowiki>|}}</nowiki>。
</div>
}}
本元模板内部使用 HTML 标记而非维基表格标记。这是制作元模板的常见做法,因为维基表格标记存在若干缺陷,例如难以在参数中使用解析器函数和特殊字符。
'''管理员注意:'''MediaWiki 不会像处理普通页面那样解析和转换系统消息中的 HTML 标记。例如 <code><br></code> 不会自动转换为 <code><br /></code>,缺失的 <code></td></code> 与 <code></tr></code> 标签不会自动补全。因此请确保系统消息中的 HTML 代码为有效的 XHTML,即闭合所有开启的标签。不过,常规维基标记在多数系统消息中可正常工作。
更多技术细节参见[[Template talk:Fmbox|讨论页]]。由于本模板与{{tl|mbox}}、{{tl|ambox}}、{{tl|tmbox}}和{{tl|ombox}}的工作方式几乎完全相同,它们的讨论页及相关页面也可能包含更多细节。
== 参见 ==
{{Mbox templates see also}}
<includeonly>
| |||