模板:Font color

來自維基學院
(重新導向自Template:Fontcolor

文件圖示 模板文件[檢視] [編輯] [歷史] [清除快取]

用途[編輯原始碼]

{{ Font color }} 你可以這樣插入有顏色的文字 , 以及 其他。 你也可以通過 background 指定背景色。

{{ Font color }} 也可以給維基鏈接上色。 通常 [[ wikilink ]]wikilink, 不過我們用 {{ font color }} 和 |link = 來創建一個黑紫色的。 →    wikilink    你可以通過 |link= 參數創建到達任何頁面的鏈接。

這個模板使用最新的 Wikipedia:HTML5 語法,Template:Clarify timeframe/sandbox 為你加入 span 標籤: <span style=color:color>……</span><span style=background-color:color>……</span>,以增強頁面可讀性。

用法[編輯原始碼]

{{Font color}} 有單色和雙色版:

{{font color | 文字顏色 | 文字 }}
{{font color | 文字顏色 | 背景顏色 | 文字 }}.

兩種格式都有一個 |link= 選項,用於給維基鏈接添加顏色。

|link=yes[[文字]]
|link=fullpagename[[页面地址]]

你也可以使用其他參數

{{font color | fg=color | text=text }}
{{font color | fg=文字顏色 | bg=背景顏色 | text=文字 }}

你也可以 |fg= 或者 |bg=,但如果你這麼用了, 就必須使用 |text=。 (參見 Help:Template#Parameters。)

空格不是問題

.{{font color|tan|green|text with four words}}..text with four words.
. {{font color|tan|green|text with four words}} .. text with four words .
. {{ font color | tan | green | text with four words }} .. text with four words .

參數[編輯原始碼]

Use / description Default value
{{{1}}} 文本顏色 inherited
{{{2}}} 文本
link =yes or =fullpagename
Or
Use / description Default value
{{{1}}} 文本顏色 inherited
{{{2}}} 背景顏色 inherited
{{{3}}} 文字
link =yes or =頁面全名

樣例[編輯原始碼]

Markup Renders as
{{ font color | green | green text }} green text
{{ font color | blue | do not style text as a link }} do not style text as a link
{{ font color || yellow | default text in yellow background }} default text in yellow background
{{ font color | bg=yellow | text = default text in yellow background }} default text in yellow background
{{ font color | white | black | white with black background }} white with black background
{{ font color | #ffffff | #000000 | white with black background }} ([[hexadecimal colors]]) white with black background (hexadecimal colors)
Markup Renders as
{{ font color | white | blue | Wikipedia:Example | link = yes }} Wikipedia:Example
{{ font color | white | blue | Wikipedia:Example | link = Wikipedia:Sandbox }} Wikipedia:Example
{{ font color | text = Wikipedia:Example | link = Wikipedia:Sandbox | bg = blue | fg = white }} Wikipedia:Example

The |link= parameter is a good way to colorize wikilinks, and it is about as much typing as the pipe trick.

Although a wikilink accepts a font color (or other template or markup):

[[Wikipedia:Example|{{font color|white|blue|the Wikipedia:Example page}}]]
the Wikipedia:Example page (a font-colored link),

a font color does not accept a wikilink, it creates wikilinks itself with |link=.

  • {{ font color | green | violet | Wikipedia:Example | link=yes }} → Wikipedia:Example (a |link= {{ font color }})
  • ☒N{{ font color | green | violet | the [[Wikipedia:Example]] page}} → the Wikipedia:Example page (Text with [[wikilink brackets]] overrides the designated color)
  • ☒N{{ font color | green | violet | [[Wikipedia:Exammple]] }} → the Wikipedia:Exammple page (Text with [[wikilink brackets]] overrides the designated color)

For more examples see /testcases. For actual mainspace template usage, here are search links for

參見[編輯原始碼]