Template:Radial-gradient/doc: Difference between revisions

From Official Kodi Wiki
Jump to navigation Jump to search
m (→‎Usage: grammar)
No edit summary
 
(14 intermediate revisions by 7 users not shown)
Line 1: Line 1:
{{Documentation subpage}}
{{Documentation subpage}}
{{Under construction}}
This template creates a radial gradient background. This currently works in Firefox (3.6 and up), Opera (12.0 and up), Safari (5.1 and up), Google Chrome (10 and up) and Internet Explorer 10.
<!-- PLEASE ADD CATEGORIES AND INTERWIKIS AT THE BOTTOM OF THIS PAGE -->
 
This template creates a radial gradient background. This currently works in Firefox (3.6 and up), Safari (5.1 and up), Google Chrome (10 and up) and Internet Explorer 10. Opera is expected to add support in version 12.


== Usage ==
== Usage ==


Use within a CSS style tag. The template uses the <tt>background-image</tt> property.
Use within a CSS style tag. The template uses the <code>background-image</code> property.


<tt><nowiki><div style="{{radial-gradient | position | shape [size] | #color [stop], #color [stop][, #color [stop], ...] }}">Lorem ipsum...</div></nowiki></tt>
<code><nowiki><div style="{{radial-gradient | position | shape [size] | #color [stop], #color [stop][, #color [stop], ...] }}">Lorem ipsum...</div></nowiki></code>


#<tt>position</tt> – Mandatrory. Specify the X and Y position of the center of the gradient. This can be any valid CSS position value.  
#<code>position</code> – Mandatrory. Specify the X and Y position of the center of the gradient. This can be any valid CSS position value.  
#<tt>shape</tt> – Mandatory. Specify the shape of the gradient using keywords or CSS size values. Valid keywords are:
#<code>shape</code> – Mandatory. Specify the shape of the gradient using keywords or CSS size values. Valid keywords are:
#*<tt>ellipse</tt>
#*<code>ellipse</code>
#*<tt>circle</tt>
#*<code>circle</code>
#<tt>size</tt> – Optional. Specify the size of the radial using keywords or CSS size values.{{ref|a|note 1}} Valid keywords are:
#<code>size</code> – Optional. Specify the size of the radial using keywords or CSS size values.<ref>Firefox does ''not'' yet support explicit size values, only keywords.</ref> Valid keywords are:
#*<tt>farthest-corner</tt> (or <tt>cover</tt>); Extends the radial to the farthest element corner, ensuring the gradient covers the entire element. This is the default.
#*<code>farthest-corner</code> (or <code>cover</code>); Extends the radial to the farthest element corner, ensuring the gradient covers the entire element. This is the default.
#*<tt>closest-corner</tt>; Extends the radial to the closest corner.
#*<code>closest-corner</code>; Extends the radial to the closest corner.
#*<tt>farthest-side</tt>; Extends the radial to the farthest edge.
#*<code>farthest-side</code>; Extends the radial to the farthest edge.
#*<tt>closest-side</tt> (or <tt>contain</tt>); Extends the radial the the closest edge, ensuring the gradient does not extend beyond the elements borders.
#*<code>closest-side</code> (or <code>contain</code>); Extends the radial to the closest edge, ensuring the gradient does not extend beyond the element's borders.
#<tt>color</tt> – The first two colors are mandatory. You can define any number of additional colors, separated with commas.
#<code>color</code> – The first two colors are mandatory. You can define any number of additional colors, separated with commas.
#<tt>stop</tt> – Optional. You can specify a stop position for each color using a percentage (e.g. 45%) or pixels (e.g. 60px).
#<code>stop</code> – Optional. You can specify a stop position for each color using a percentage (e.g. 45%) or pixels (e.g. 60px).


{{note|a|note 1}}: Firefox does ''not'' yet support explicit size values, only keywords.
===Notes===
<references />


== Technical notes ==
== Technical notes ==
Line 29: Line 27:
The template does not assign a default background-color, and therefor does not provide an automatic fallback for browsers that do not support gradients. To provide a fallback, always specify a background color in front of the template.
The template does not assign a default background-color, and therefor does not provide an automatic fallback for browsers that do not support gradients. To provide a fallback, always specify a background color in front of the template.


This template uses the new CSS3 properties for radial gradients: <tt>-moz-radial-gradient</tt>, <tt>-ms-radial-gradient</tt>, <tt>-o-radial-gradient</tt>, <tt>-webkit-radial-gradient</tt> and <tt>radial-gradient</tt>.
This template uses the new CSS3 properties for radial gradients: <code>-moz-radial-gradient</code>, <code>-ms-radial-gradient</code>, <code>-o-radial-gradient</code>, <code>-webkit-radial-gradient</code> and <code>radial-gradient</code>.


== Examples ==
== Examples ==


* <tt><nowiki><div style="{{radial-gradient|100px center|ellipse cover|#ffdddd, #ddddff}}">Lorem ipsum...</div></nowiki></tt> will produce
* <code><nowiki><div style="{{radial-gradient|100px center|ellipse cover|#ffdddd, #ddddff}}">Lorem ipsum...</div></nowiki></code> will produce


<div style="{{radial-gradient|100px center|ellipse cover|#ffdddd, #ddddff}}">Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.</div>
<div style="width: 480px; {{radial-gradient|100px center|ellipse cover|#ffdddd, #ddddff}}">Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.</div>


* <tt><nowiki><div style="{{radial-gradient|center|circle|#ffdddd, #ddffdd 50%, #ddddff}}">Lorem ipsum...</div></nowiki></tt> will produce
* <code><nowiki><div style="{{radial-gradient|center|ellipse contain|#ffdddd, #ddffdd 50%, #ddddff}}">Lorem ipsum...</div></nowiki></code> will produce


<div style="{{radial-gradient|center|circle|#ffdddd, #ddffdd 50%, #ddddff}}">Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.</div>
<div style="width: 480px; {{radial-gradient|center|ellipse contain|#ffdddd, #ddffdd 50%, #ddddff}}">Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.</div>


* <tt><nowiki><div style="{{radial-gradient|top|ellipse|#ffdddd, #ddddff}}">Lorem ipsum...</div></nowiki></tt> will produce
* <code><nowiki><div style="{{radial-gradient|top|circle|#ffdddd, #ddddff}}">Lorem ipsum...</div></nowiki></code> will produce


<div style="{{radial-gradient|top|ellipse|#ffdddd, #ddddff}}">Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.</div>
<div style="width: 480px; {{radial-gradient|top|circle|#ffdddd, #ddddff}}">Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.</div>


== Considerations ==
== Considerations ==


Above examples use contrasting colors to show the effect more clearly. It is best to use subtle differences in color to enhance the appearance, rather than radically change it. This also minimizes the effects between browsers that do and do not support gradients.
Above examples use contrasting colors to show the effect more clearly. It is best to use subtle differences in color to enhance the appearance, rather than radically change it. This also minimizes the effects between browsers that do and do not support gradients.
== Compatibility ==
* See [https://developer.mozilla.org/en-US/docs/CSS/radial-gradient#Browser_compatibility radial-gradient] on the Mozilla Developer Network for all broswer compatibility details.


== See also ==
== See also ==
Line 56: Line 57:


<includeonly>
<includeonly>
<!-- CATEGORIES AND INTERWIKIS HERE, THANKS -->
[[Category:Formatting templates]]
[[Category:Cross-browser compatibility templates]]
 
</includeonly>
</includeonly>

Latest revision as of 09:17, 5 June 2013

This template creates a radial gradient background. This currently works in Firefox (3.6 and up), Opera (12.0 and up), Safari (5.1 and up), Google Chrome (10 and up) and Internet Explorer 10.

Usage

Use within a CSS style tag. The template uses the background-image property.

<div style="{{radial-gradient | position | shape [size] | #color [stop], #color [stop][, #color [stop], ...] }}">Lorem ipsum...</div>

  1. position – Mandatrory. Specify the X and Y position of the center of the gradient. This can be any valid CSS position value.
  2. shape – Mandatory. Specify the shape of the gradient using keywords or CSS size values. Valid keywords are:
    • ellipse
    • circle
  3. size – Optional. Specify the size of the radial using keywords or CSS size values.[1] Valid keywords are:
    • farthest-corner (or cover); Extends the radial to the farthest element corner, ensuring the gradient covers the entire element. This is the default.
    • closest-corner; Extends the radial to the closest corner.
    • farthest-side; Extends the radial to the farthest edge.
    • closest-side (or contain); Extends the radial to the closest edge, ensuring the gradient does not extend beyond the element's borders.
  4. color – The first two colors are mandatory. You can define any number of additional colors, separated with commas.
  5. stop – Optional. You can specify a stop position for each color using a percentage (e.g. 45%) or pixels (e.g. 60px).

Notes

  1. Firefox does not yet support explicit size values, only keywords.

Technical notes

The template does not assign a default background-color, and therefor does not provide an automatic fallback for browsers that do not support gradients. To provide a fallback, always specify a background color in front of the template.

This template uses the new CSS3 properties for radial gradients: -moz-radial-gradient, -ms-radial-gradient, -o-radial-gradient, -webkit-radial-gradient and radial-gradient.

Examples

  • <div style="{{radial-gradient|100px center|ellipse cover|#ffdddd, #ddddff}}">Lorem ipsum...</div> will produce
Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.
  • <div style="{{radial-gradient|center|ellipse contain|#ffdddd, #ddffdd 50%, #ddddff}}">Lorem ipsum...</div> will produce
Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.
  • <div style="{{radial-gradient|top|circle|#ffdddd, #ddddff}}">Lorem ipsum...</div> will produce
Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.

Considerations

Above examples use contrasting colors to show the effect more clearly. It is best to use subtle differences in color to enhance the appearance, rather than radically change it. This also minimizes the effects between browsers that do and do not support gradients.

Compatibility

  • See radial-gradient on the Mozilla Developer Network for all broswer compatibility details.

See also