文档图示 模板文档

用途

{{Font color}} 你可以这样插入有颜色的文字绿,以及 其他。你也可以通过 background指定背景色。

{{Font color}} 也可以给维基链接上色。通常 [[ wikilink ]] → wikilink, 不过我们用 {{ font color }} 和 |link = 来创建一个黑紫色的。 →    wikilink   你可以通过 |link= 参数创建到达任何页面的链接。

这个模板使用最新的 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 =页面全名

样例

MarkupRenders 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)
MarkupRenders as
{{ font color | white | blue | Wikipedia:Example | link = yes }}Baike: Example
{{ font color | white | blue | Wikipedia:Example | link = Wikipedia:Sandbox }}Baike: Example
{{ font color | text = Wikipedia:Example | link = Wikipedia:Sandbox | bg = blue | fg = white }}Baike: 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):

[[Baike: 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 }} → Baike: Example (a |link= {{ font color }})
  • ☒N{{ font color | green | violet | the [[Wikipedia:Example]] page}} → the Baike: 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

参见