Difference between revisions of "Template:Hover/doc"
Martin Zhao (talk | contribs) (Created page with "本模板用于图片以外的hover切换效果(比如文字,css自绘图形),但也可以应用到图片。使用了widget:Hover。 ==注意== 使用本模板时...") |
(Translated) |
||
Line 1: | Line 1: | ||
− | + | This template is used for hover switching effects other than pictures (such as texts, css customized graphics), but it can also be applied to pictures. [[Widget:Hover]] is used. | |
− | + | <!-- | |
==注意== | ==注意== | ||
使用本模板时请检查移动端有无显示问题。如果不知道如何解决移动端的显示问题,可以尝试替换为{{tl|TextHover}}模板。 | 使用本模板时请检查移动端有无显示问题。如果不知道如何解决移动端的显示问题,可以尝试替换为{{tl|TextHover}}模板。 | ||
+ | --><!-- No mobile view for EnMGP --> | ||
+ | == Parameters & Instances == | ||
+ | There are 15 parameters in total, of which two are required. | ||
− | |||
− | |||
{| class="wikitable" style="text-align: center;" | {| class="wikitable" style="text-align: center;" | ||
− | |+ | + | |+List of parameters |
|- | |- | ||
− | ! | + | ! Name of parameter |
− | ! | + | ! Whether necessary |
− | ! | + | ! Style of parameter |
− | ! | + | ! Instance of parameter |
− | ! | + | ! Role of parameter |
|- | |- | ||
− | | before || rowspan="2" | | + | | before || rowspan="2" | Yes || Any || You can see me. || Set the characters displayed when the mouse is not hovered. |
|- | |- | ||
− | | after || | + | | after ||Any || Now you can't see. || Set the characters displayed when the mouse is hovered. |
|- | |- | ||
− | | width || rowspan="2" | | + | | width || rowspan="2" | No, the default is the largest required size. || rowspan="2" | Number(+unit) || rowspan="2" | 150<br />10em || Set the width of the displayed characters. The default is px when there is no unit. |
|- | |- | ||
− | | height || | + | | height || Set the height of the displayed characters. The default is px when there is no unit. |
|- | |- | ||
− | | float || | + | | float || No, the default is none. || colspan=2 | left / right || Float the hover block~ |
<!-- |- | <!-- |- | ||
| mode || 否,默认为0 || colspan=2 | 0 / 1 || 展示方式不同_(:зゝ∠)_ --><!-- Shirrak前辈暂时拿掉了mode参数 --> | | mode || 否,默认为0 || colspan=2 | 0 / 1 || 展示方式不同_(:зゝ∠)_ --><!-- Shirrak前辈暂时拿掉了mode参数 --> | ||
|- | |- | ||
− | | hp || | + | | hp || No, nothing happens if not specified. || colspan=2 | relative/absolute/static/fixed || Control the property position of class hover (HoverPositionOverride). |
|- | |- | ||
− | | dis || | + | | dis || No, nothing happens if not specified. || colspan=2 | inline-block/block || Control the property display of class hover (HoverDisplayOverride). |
|- | |- | ||
− | | hb || | + | | hb || No, nothing happens if not specified. || colspan=2 | none/inline-block/block || Control the property display of class hoverbefore (HoverBeforeDisplay). |
|- | |- | ||
− | | ha || | + | | ha || No, nothing happens if not specified. || colspan=2 | none/inline-block/block || Control the property display of class hoverafter (HoverAfterDisplay). |
|- | |- | ||
− | | onhb || | + | | onhb || No, nothing happens if not specified. || colspan=2 | none/inline-block/block || Control the property display of class hoverbefore when mouse is hovered (HoverBeforeDisplayOnHover). |
|- | |- | ||
− | | onha || | + | | onha || No, nothing happens if not specified. || colspan=2 | none/inline-block/block || Control the property display of class hoverafter when mouse is hovered (HoverAfterDisplayOnHover). |
|- | |- | ||
− | | css || | + | | css || No, nothing happens if not specified. || colspan=2 rowspan=3 | Customized || Customized style |
|- | |- | ||
− | | cssb || | + | | cssb || No, nothing happens if not specified. || Customized style (class hoverbefore) |
|- | |- | ||
− | | cssa || | + | | cssa || No, nothing happens if not specified. || Customized style (class hoverafter) |
|- | |- | ||
|} | |} | ||
− | ''' | + | '''Note''': If <code>onhb</code> and <code>onha</code> are specified, <code>hoverafter</code> shows only when the mouse hovers over <code>hoverbefore</code>. |
− | + | Examples with complete code are as follows: | |
− | ; | + | ;For pictures: |
− | + | Similar to {{tl|PicHover}}, but pictures need to be directly linked. | |
<pre> | <pre> | ||
{{Hover|before=[[File:ZhMoegirl15.2.png|link=]]|after=[[File:Zh2014 moegirlpedia logo.png|link=]]|width=150|height=180}} | {{Hover|before=[[File:ZhMoegirl15.2.png|link=]]|after=[[File:Zh2014 moegirlpedia logo.png|link=]]|width=150|height=180}} | ||
</pre> | </pre> | ||
− | + | Outcome: | |
{{Hover|before=[[File:ZhMoegirl15.2.png|link=]]|after=[[File:Zh2014 moegirlpedia logo.png|link=]]|width=150|height=180<!--|mode=1-->}} | {{Hover|before=[[File:ZhMoegirl15.2.png|link=]]|after=[[File:Zh2014 moegirlpedia logo.png|link=]]|width=150|height=180<!--|mode=1-->}} | ||
− | ; | + | ;For texts: |
− | + | Call directly: | |
<pre> | <pre> | ||
− | {{Hover|before={{color|blue| | + | {{Hover|before={{color|blue|You can see me.}}|after={{color|red|Now you can't see.}}}} |
</pre> | </pre> | ||
− | + | Outcome: | |
− | {{Hover|before={{color|blue| | + | {{Hover|before={{color|blue|You can see me.}}|after={{color|red|Now you can't see.}}}} |
− | ; | + | ;Guidelines for displaying text in lines/paragraphs: |
− | ''' | + | '''Template {{tl|HoverInline}} is recommended.''' |
− | * | + | *HTML tags are required, div and span are both acceptable, indentation types like asterisks and half-width colons are also with tags. |
− | : | + | :The easiest way to use in line is wrapping the whole paragraph with <code><nowiki><poem>...</poem></nowiki></code>. |
− | * | + | *Set the display parameter to inline-block. |
− | * | + | *For CSS of long elements, add <code>position:relative;</code>. |
<pre> | <pre> | ||
<poem> | <poem> | ||
− | + | Hahaha, {{Hover|display=inline-block|before={{color|blue|you can see me}}|cssa=position: relative;|after={{color|red|now you can't see}}}}?! | |
</poem> | </poem> | ||
− | * | + | *Hahaha, {{Hover|display=inline-block|before={{color|blue|you can see me}}|cssa=position: relative;|after={{color|red|now you can't see}}}}?! |
</pre> | </pre> | ||
− | + | Outcome: | |
<poem> | <poem> | ||
− | + | Hahaha, {{Hover|display=inline-block|before={{color|blue|you can see me}}|cssa=position: relative;|after={{color|red|now you can't see}}}}?! | |
</poem> | </poem> | ||
− | * | + | *Hahaha, {{Hover|display=inline-block|before={{color|blue|you can see me}}|cssa=position: relative;|after={{color|red|now you can't see}}}}?! |
− | ''' | + | '''For customized graphics''' |
<pre> | <pre> | ||
− | + | Similar to texts. | |
</pre> | </pre> | ||
− | + | Outcome: | |
{{Hover | {{Hover | ||
|before= <div style="width:40px;height:54px;background-color:#f9f9f9;margin-top:0px;overflow:hidden;border:1px solid #f9f9f9;"> | |before= <div style="width:40px;height:54px;background-color:#f9f9f9;margin-top:0px;overflow:hidden;border:1px solid #f9f9f9;"> | ||
Line 107: | Line 108: | ||
}} | }} | ||
− | == | + | == Related templates == |
{{tl|Moe-hover}} | {{tl|Moe-hover}} | ||
{{tl|Hovers}} | {{tl|Hovers}} |
Latest revision as of 01:55, 24 August 2020
This template is used for hover switching effects other than pictures (such as texts, css customized graphics), but it can also be applied to pictures. Widget:Hover is used.
Parameters & Instances
There are 15 parameters in total, of which two are required.
Name of parameter | Whether necessary | Style of parameter | Instance of parameter | Role of parameter |
---|---|---|---|---|
before | Yes | Any | You can see me. | Set the characters displayed when the mouse is not hovered. |
after | Any | Now you can't see. | Set the characters displayed when the mouse is hovered. | |
width | No, the default is the largest required size. | Number(+unit) | 150 10em |
Set the width of the displayed characters. The default is px when there is no unit. |
height | Set the height of the displayed characters. The default is px when there is no unit. | |||
float | No, the default is none. | left / right | Float the hover block~ | |
hp | No, nothing happens if not specified. | relative/absolute/static/fixed | Control the property position of class hover (HoverPositionOverride). | |
dis | No, nothing happens if not specified. | inline-block/block | Control the property display of class hover (HoverDisplayOverride). | |
hb | No, nothing happens if not specified. | none/inline-block/block | Control the property display of class hoverbefore (HoverBeforeDisplay). | |
ha | No, nothing happens if not specified. | none/inline-block/block | Control the property display of class hoverafter (HoverAfterDisplay). | |
onhb | No, nothing happens if not specified. | none/inline-block/block | Control the property display of class hoverbefore when mouse is hovered (HoverBeforeDisplayOnHover). | |
onha | No, nothing happens if not specified. | none/inline-block/block | Control the property display of class hoverafter when mouse is hovered (HoverAfterDisplayOnHover). | |
css | No, nothing happens if not specified. | Customized | Customized style | |
cssb | No, nothing happens if not specified. | Customized style (class hoverbefore) | ||
cssa | No, nothing happens if not specified. | Customized style (class hoverafter) |
Note: If onhb
and onha
are specified, hoverafter
shows only when the mouse hovers over hoverbefore
.
Examples with complete code are as follows:
- For pictures
Similar to {{PicHover}}, but pictures need to be directly linked.
{{Hover|before=[[File:ZhMoegirl15.2.png|link=]]|after=[[File:Zh2014 moegirlpedia logo.png|link=]]|width=150|height=180}}
Outcome:
- For texts
Call directly:
{{Hover|before={{color|blue|You can see me.}}|after={{color|red|Now you can't see.}}}}
Outcome:
You can see me.
Now you can't see.
- Guidelines for displaying text in lines/paragraphs
Template {{HoverInline}} is recommended.
- HTML tags are required, div and span are both acceptable, indentation types like asterisks and half-width colons are also with tags.
- The easiest way to use in line is wrapping the whole paragraph with
<poem>...</poem>
.
- Set the display parameter to inline-block.
- For CSS of long elements, add
position:relative;
.
<poem> Hahaha, {{Hover|display=inline-block|before={{color|blue|you can see me}}|cssa=position: relative;|after={{color|red|now you can't see}}}}?! </poem> *Hahaha, {{Hover|display=inline-block|before={{color|blue|you can see me}}|cssa=position: relative;|after={{color|red|now you can't see}}}}?!
Outcome:
Hahaha, ?!
you can see me
now you can't see
- Hahaha, ?!you can see menow you can't see
For customized graphics
Similar to texts.
Outcome:
Related templates
{{Moe-hover}}
{{Hovers}}