模板:Userbox/doc

维基百科,自由的百科全书
(差异) ←上一修订 | 最后版本 (差异) | 下一修订→ (差异)
跳转到导航 跳转到搜索

模板介绍[编辑]

本模板适用于建置用户框,提供用户在用户页显示用户的一些信息,以免于HTML与Wikitable参数的麻烦。

合理使用图像不得用于用户框,任何用户可在不经对方同意下,移除相关图片。

使用方式[编辑]

{{Userbox
|bodyclass     = <!--自定义HTML Class参数-->
|border-c      = <!--边框色彩 (默认与 id-c 之参数相同)-->
|border-s      = <!--边框像素大小 (默认值:1)-->
|float         = <!--流动对齐方式 left|right|none (默认值:left)-->
|id            = <!--id 图片或文字(选用,默认尺寸是x45px)-->
|id-a          = <!--id 水平对齐方式 left/center/right/justify (默认:center)-->
|id-c          = <!--id 的背景色彩 (默认:#d0d0d0)-->
|id-fc         = <!--id 的文字色彩 (默认:black)-->
|id-h          = <!--id 框的像素大小 (默认:45)-->
|id-lh         = <!--id 行高 (默认:1em)-->
|id-op         = <!--id 的其他 CSS 参数-->
|id-p          = <!--id 的单元格留白值 (默认:0 1px 0 0)-->
|id-s          = <!--id 文字点数 (默认:14)-->
|id-w          = <!--id 框长度 (默认:45)-->
|info-class    = <!--Adds an HTML class attribute to the "info" HTML table-row, to allow for styling, emission of microformats, etc.-->
|info          = <!--info 框图文内容-->
|info-a        = <!--info 框水平对齐方式 left/center/right/justify (默认:left)-->
|info-c        = <!--info 框背景色 (默认:#e0e0e0)-->
|info-fc       = <!--info 框文字色彩 (默认:black)-->
|info-lh       = <!--info 框行高 (默认:1.25em)-->
|info-op       = <!--info 框的其他CSS样式参数-->
|info-p        = <!--info 框的留白值 (默认:0 4px 0 4px)-->
|info-s        = <!--info 文字点数 (默认:8)-->
|nocat         = <!--屏蔽页面分类 (默认:false)-->
|usercategory  = <!--用户自设分类(选用)-->
|usercategory2 = <!--用户自设分类(选用)-->
|usercategory3 = <!--用户自设分类(选用)-->
}}
  • 全部参数皆为选填
  • 图像建议少于45px

多数基于HTML的表格仅用这些参数的一小部分。以下子集可以用来把HTML用户框快速转换成这里所用的格式:

{{Userbox
|border-c     = 
|id           = 
|id-c         = 
|id-fc        = 
|id-s         = 
|info         = 
|info-c       = 
|info-fc      = 
|info-lh      = 
|info-s       = 
|nocat        = {{{nocat|}}}
|usercategory = 
}}

示例[编辑]

代码 效果
{{Userbox}}
{{{info}}}
{{Userbox
|border-c = #aaffaa
|border-s = 2
|id       = foo
|id-c     = #ffffee
|id-s     = 20
|info     = ''foo bar''
|info-c   = #ffeeff
|info-s   = 12
}}
foofoo bar
以下展示高度超过45px的用户框的默认外观,比较一下上下两个用户框的差异。
{{Userbox
|border-c = #aaffaa
|border-s = 2
|id       = foo logo
|id-c     = #ffffee
|info     = ''We are trying to see 
default distance in between text 
lines, see the distance in 
between cell content and its border, 
and also see total height.''
|info-c   = #ffeeff
}}
foo logoWe are trying to see default distance in between text lines, see the distance in between cell content and its border, and also see total height.
以下展示怎样能修改用户框并进一步指定参数来降低用户框的高度以达到推荐的45px,即使有四行文字。在四行文字之下,单元格边距参数info-p也可以设置成1pt 1pt 1pt 2pt,或者1pt 2pt以达到更好的效果。
{{Userbox
|border-c = #aaffaa
|border-s = 1
|id       = foo logo
|id-c     = #ffffee
|id-lh    = 1.1em
|id-s     = 14
|info     = ''We have specified values 
to lessen the distance in between 
text lines & padding space in between 
cell content and its border.''
|info-c   = #ffeeff
|info-lh  = 1.05em
|info-p   = 1pt
|info-s   = 8
}}
foo logoWe have specified values to lessen the distance in between text lines & padding space in between cell content and its border.
以下针对高级用户,展示怎样指定其他CSS属性,例如,font-family调整字体,text-align从默认参数调整对齐方式。如下所示,右边是2个用户框:上面一个是不带font-family或text-align参数;下面一个是以填写info-op参数来使用此类代码显示的。
{{Userbox
|border-c = #afa
|border-s = 2
|id       = foo logo
|id-c     = #ffe
|id-lh    = 1.1em
|id-s     = 14
|info     = foo bar
|info-c   = #fef
|info-op  = font-family:'Courier New'; text-align:center;
|info-s   = 14
}}
foo logofoo bar

 
foo logofoo bar

模板数据[编辑]

以下是该模板的模板数据,适用于可视化编辑器等工具。

Userbox模板数据

<templatedata> { "description": "本模板适用于建置用户框,提供用户在用户页显示用户的一些信息,以免于HTML与Wikitable参数的麻烦。", "params": { "bodyclass": { "label": "bodyclass", "description": "自定义HTML Class参数", "type": "string", "default": "id-c" }, "border-c": { "label": "border-c", "description": "边框色彩", "type": "string" }, "border-s": { "label": "border-s", "description": "边框像素大小", "type": "string", "default": "1" }, "float": { "label": "float", "description": "流动对齐方式 left|right|none", "type": "string", "default": "left" }, "id": { "label": "id", "description": "id 图片或文字(选用)", "type": "string", "default": "x45px" }, "id-a": { "label": "id-a", "description": "id 水平对齐方式 left/center/right/justify", "type": "string", "default": "center" }, "id-c": { "label": "id-c", "description": "id 的背景色彩", "type": "string", "default": "#d0d0d0" }, "id-fc": { "label": "id-fc", "description": "id 的文字色彩", "type": "string", "default": "black" }, "id-h": { "label": "id-h", "description": "id 框的像素大小", "type": "string", "default": "45" }, "id-lh": { "label": "id-lh", "description": "id 行高", "type": "string", "default": "1em" }, "id-op": { "label": "id-op", "description": "id 的其他 CSS 参数", "type": "string" }, "id-p": { "label": "id-p", "description": "id 的单元格留白值", "type": "string", "default": "0 1px 0 0" }, "id-s": { "label": "id-s", "description": "id 文字点数", "type": "string", "default": "14" }, "id-w": { "label": "id-w", "description": "id 框长度,单位是像素", "type": "string", "default": "45" }, "info-class": { "label": "info-class", "description": "Adds an HTML class attribute to the “info” HTML table-row, to allow for styling, emission of microformats, etc.", "type": "string" }, "info": { "label": "info", "description": "info 框图文内容", "type": "string" }, "info-a": { "label": "info-a", "description": "info 框水平对齐方式 left/center/right/justify", "type": "string", "default": "left" }, "info-c": { "label": "info-c", "description": "info 框背景色", "type": "string", "default": "#e0e0e0" }, "info-fc": { "label": "info-fc", "description": "info 框文字色彩", "type": "string", "default": "black" }, "info-lh": { "label": "info-lh", "description": "info 框行高", "type": "string", "default": "1.25em" }, "info-op": { "label": "info-op", "description": "info 框的其他CSS样式参数", "type": "string" }, "info-p": { "label": "info-p", "description": "info 框的留白值", "type": "string", "default": "0 4px 0 4px" }, "info-s": { "label": "info-s", "description": "info 文字点数", "type": "string", "default": "8" }, "nocat": { "label": "nocat", "description": "屏蔽页面分类", "type": "string", "default": "false" }, "usercategory": { "label": "usercategory", "description": "用户自设分类(选用)", "type": "string" }, "usercategory2": { "label": "usercategory2", "description": "用户自设分类(选用)", "type": "string" }, "usercategory3": { "label": "usercategory3", "description": "用户自设分类(选用)", "type": "string" } } } </templatedata>

重定向[编辑]

参见[编辑]

微格式[编辑]

bodyclass
This parameter is inserted into the "class" attribute for the userbox as a whole.
info-class
This parameter is inserted into the "class" attribute for the info component.

This template supports the addition of microformat information.[翻译请求] This is done by adding "class" attributes to various data cells, indicating what kind of information is contained within. To flag a userbox as containing hCard information about a person, for example, add the following parameter:

|bodyclass = vcard

or

|info-class = vcard

then (for example):

|title = ... the books of <span class="fn">[[Iain Banks]]</span>

... and so forth.

Examples include:

有关微格式的参数设置,请参考微格式专题