跳至內容

模板:Userbox

出自微國家百科
{{{info}}}
-{zh-cn:文档; zh-tw:文件;}-图示 模板文件[檢視] [編輯] [歷史] [清除快取]

模板:May be substituted

模板:Uses templatestyles

This template can be used to quickly create a userbox for display on a user's user page without having to know HTML or Wikitable syntax.

Nonfree images must not be displayed in userboxes, and are subject to summary removal by any editor without any notice being required.

Sandbox reminder

Usage

{{userbox
| bodyclass     = <!--Adds an HTML class attribute to the entire template's HTML table, to allow for styling, emission of microformats, etc.-->
| border-c      = <!--border color (default=id-c or #999999)-->
| border-s      = <!--border width in pixels (default=1)-->
| float         = <!--left|right|none (default=left)-->
| id            = <!--id image or text (image size should normally not exceed 90x45px)-->
| id-a          = <!--id horizontal alignment left/center/right/justify (default=center)-->
| id-c          = <!--id background color (default=#DDDDDD)-->
| id-fc         = <!--id font color (default=info-fc or black)-->
| id-h          = <!--id box height in pixels (default=45)-->
| id-lh         = <!--id line height (default=1.25em)-->
| id-op         = <!--id other CSS parameters-->
| id-p          = <!--id cell padding (default=0 1px 0 0)-->
| id-s          = <!--id text size in points (default=14)-->
| id-w          = <!--id box width in pixels (default=45)-->
| info-class    = <!--Adds an HTML class attribute to the "info" HTML table-row, to allow for styling, emission of microformats, etc.-->
| info          = <!--info text or image-->
| info-a        = <!--info horizontal alignment left/center/right/justify (default=left)-->
| info-c        = <!--info background color (default=#EEEEEE)-->
| info-fc       = <!--info font color (default=black)-->
| info-lh       = <!--info line height (default=1.25em)-->
| info-op       = <!--info other CSS parameters-->
| info-p        = <!--info padding (default=0 4px 0 4px)-->
| info-s        = <!--info text size in points (default=8)-->
| nocat         = {{{nocat|}}}<!--block page category declarations; see [[WP:NOCAT]] (default=false)-->
| usercategory  = <!--user category (optional, unlinked and without the "Category:" part)-->
| usercategory2 = <!--user category (optional)-->
| usercategory3 = <!--user category (optional)-->
| usercategory4 = <!--user category (optional)-->
| usercategory5 = <!--user category (optional)-->
}}
  • All parameters are optional.
  • Images should normally be scaled to x45px or less.

Most HTML-based tables use only a handful of these attributes. The following subset can be used to quickly convert an HTML userbox into the format used here:

{{userbox
| border-c = 
| id       = 
| id-c     = 
| id-fc    = 
| id-s     = 
| info     = 
| info-c   = 
| info-fc  = 
| info-lh  = 
| info-s   = 
}}

Examples

Code Result
{{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
Below example shows the default appearance of a userbox, which is (much) higher than the 45px.
Compare the height of the one below with the above userbox.
{{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.
Below example shows how we can change that userbox and further specify parameters to bring down
the overall height of the userbox to the recommended height of 45px, even with four text lines.
Cell padding parameter "info-p" can also be set at "1pt 1pt 1pt 2pt", or "1pt 2pt" for better appearance,
when there are 4 text lines.
{{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 between 
text lines and padding space 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 between text lines and padding space between cell content and its border.
Below example is for advanced users, showing how we can specify other CSS properties, for example, "font-family",
to change the font or "text-decoration" to add lines around the text. Below, on the right side are two userboxes:
the top one is displayed without either parameters; and the bottom userbox is displayed by using the below code,
with the help of the "info-op" field.
{{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', monospace; text-decoration: wavy overline green;
| info-s        = 14
}}
foo logofoo bar

 
foo logofoo bar

Microformats

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):

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

...and so forth.

Examples include:

See Wikipedia:WikiProject Microformats for more information on adding microformat information to Wikipedia.

Template Data

以下是该模板的-{zh-cn:模板数据;zh-tw:模板資料}-,适用于-{zh-cn:可视化编辑器;zh-tw:視覺化編輯器;}-等工具。

Userbox-{zh-cn:模板数据;zh-tw:模板資料}-

This template can be used to quickly create a userbox for display on a user's user page without having to know HTML or Wikitable syntax.

模板參數[編輯模板資料]

此模板以參數區塊格式為優先。

參數描述類型狀態
Body classbodyclass

Adds an HTML class attribute to the entire template's HTML table, to allow for styling, emission of microformats, etc.

字串非必填
Floatfloat

left|right|none

建議值
left right none
預設
left
字串非必填
Border colorborder-c border-color

Color of the outer border

預設
#999
字串非必填
Border widthborder-s border-width

border width in pixels

預設
1
數值非必填
Logoid 3 logo

id image or text

內容建議
Logo content horizontal alignmentid-a

Horizontal alignment of logo content; left/center/right/justify

建議值
left center right justify
預設
center
字串非必填
Logo background colorlogo-background

Background color of logo

預設
#ddd
字串非必填
id-cid-c 1

Two-in-one alias for border color and logo background color. Lower priority than border-c and logo-background

範例
#d0d0d0
字串非必填
Logo font colorid-fc logo-color

Logo font color; if not specified, defaults to info font color

預設
black
字串非必填
Logo heightid-h logo-height

Logo box height in pixels

預設
45
數值非必填
Logo font sizeid-s 5 logo-size

Logo text size in points

預設
14
字串非必填
Logo line heightid-lh logo-line-height

Logo line height

預設
1.25em
字串非必填
Logo paddingid-p logo-padding

Logo cell padding

預設
0 1px 0 0
字串非必填
Logo widthid-w logo-width

id box width in pixels

預設
45
數值非必填
Logo CSS classesid-class

CSS class or classes for the logo; optional

預設
(none)
字串非必填
Extra logo stylingid-op logo-other-param

Add additional arbitrary CSS styling to the logo

範例
opacity: 0.25
字串非必填
Infoinfo 4

info text or image

內容必填
Info content horizontal alignmentinfo-a

Horizontal alignment of info content; left/center/right/justify

建議值
left center right justify
預設
left
字串非必填
Info background colorinfo-c 2 info-background

Info background color

預設
#e0e0e0
字串非必填
Info font colorinfo-fc info-color

info font color

預設
black
字串非必填
Info line heightinfo-lh info-line-height

Info line height

預設
1.25em
字串非必填
Info paddinginfo-p info-padding

info padding

預設
0 4px 0 4px
字串非必填
Info font sizeinfo-s info-size

info text size in points

預設
8
數值非必填
Info CSS classesinfo-class

Adds an HTML class attribute to the "info" HTML table-row, to allow for styling, emission of microformats, etc.

字串非必填
Extra info stylinginfo-op info-other-param

Add additional arbitrary CSS styling to the info

範例
opacity: 0.25
字串非必填
nocatnocat

block page category declarations (see WP:NOCAT)

預設
false
字串非必填
usercategoryusercategory

user category (optional)

字串非必填
usercategory2usercategory2

user category (optional)

字串非必填
usercategory3usercategory3

user category (optional)

字串非必填
usercategory4usercategory4

user category (optional)

字串非必填
usercategory5usercategory5

user category (optional)

字串非必填

See also

模板:UBT